2 Replies Latest reply on Aug 6, 2007 12:07 AM by darrylfrith

    implicit coercion of a date to an unrelated type number

    darrylfrith
      I'm using the following to select all the days in the displayed month on the date chooser.

      var start_d:Date = new Date();
      start_d.month = chooser.displayedMonth;
      start_d.date = 0;

      var end_d:Date = new Date();

      // find last day in month
      var dt:Date = new Date( chooser.displayedYear, chooser.displayedMonth + 1, 0 );

      //Alert.show(dt.toString());
      end_d.month = chooser.displayedMonth;
      end_d.date = 25;
      calendar.selectedRanges = [{rangeStart: start_d, rangeEnd: end_d}];

      I find the last day of the month by looking for day 0 of DisplayedMonth + 1. if I say "end_d.date = 25" this code works to select day 1 to 25 on the date chooser but I cannot make it work with the last day of the month when I do this : "end_d.date = dt;" I get an error implicit coercion of a date to an unrelated typoe number. So I tried this :

      var df:DateFormatter = new DateFormatter();
      df.formatString = "DD";
      var formattedDate:String = df.format(chooser.selectedDate);
      end_d.date = formattedDate;

      but I get the same error. Any Idea how to get this last date to be the last day of the month?