3 Replies Latest reply on Aug 27, 2010 12:33 AM by dgamma

    Check date variable


      Hello I want to be able to select a date from date field, and for whatever date they pick i want it to select the last day for the month they picked.

      ive got this so far:


      var configureEndDate:Date = new Date;

      var testCurrentDay:Date = new Date

      testCurrentDay = dfFrom.selectedDate;

      configureEndDate.setMonth(testCurrentDay. (what do i put here) );


      im not sure what the property for the last day of the month is, if there is any, to put on the end of testCurrentDay. Is there a work around? maybe i could do something like this:


      configureEndDate.setMonth(testCurrentDay. checkMonth() );


      functio ncheckMonth():void
                      if (configureEndDate.month == 1)

                          dfFrom.selectedDate.(what what i put here to change the month to january for the date field, i.e **/01/****)


      Thanks daniel

        • 1. Re: Check date variable
          Gregory Lafrance Level 6

          This will answer your question:


          <?xml version="1.0"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
                import mx.events.CalendarLayoutChangeEvent;
                private function setLastDay(evt:CalendarLayoutChangeEvent):void{
                  var currDate:Date = (DateField)(evt.target).selectedDate;
                  var newDate:Date = new Date();
                  var currMonth:Number = currDate.getMonth();
                  if(currMonth < 11){
                    newDate.setMonth(0, 1);
                  df.selectedDate = newDate;
            <mx:DateField id="df" change="setLastDay(event);"/>

          If this post answers your question or helps, please mark it as such.

          Greg Lafrance - Flex 2 and 3 ACE certified


          Flex Training and Support Services

          1 person found this helpful
          • 2. Re: Check date variable
            dgamma Level 1


            • 3. Re: Check date variable
              dgamma Level 1

              Works great!