title: Datefield Ranges - Flex
body: <p>I have two Datefields .Is there a way that i can set the date of second Datefield to a specified range(say three days ...?. I tried to do it but not worked .. dont know to convert date back to string and format it .. here is the code</p>
  
  <pre><code>&lt;mx:DateField disabledRanges="{[{rangeEnd: new Date(2011,05,31)}]}" id="dfield1" change="leaveDate()" parseFunction="null" width="100"  x="156" y="130"/&gt;
  &lt;mx:DateField disabledRanges="{[{rangeEnd: new Date(2011,05,31)}]}" id="dfield2"  parseFunction="null" width="100"  x="426" y="130"/&gt;
  
  private function leaveDate():void {
      //var dateLeave:Date = dfield1.selectedDate;
      var myTime:Date =dfield1.selectedDate;
      dateAdd("date", 3, myTime);
      //car formatter1:Datef
      commentField.text+=myTime+"\n"
      //dfield2.selectedDate = returnDate
  }
  public static function dateAdd(datepart:String = "", number:Number = 0, date:Date = null):Date
          {
      if (date == null) {
          date = new Date();
      }
  
      var returnDate:Date = new Date(date.time);;
  
      switch (datepart.toLowerCase()) {
          case "fullyear":
          case "month":
          case "date":
          case "hours":
          case "minutes":
          case "seconds":
          case "milliseconds":
              returnDate[datepart] += number;
              break;
          default:
              /* Unknown date part, do nothing. */
              break;
      }
        return returnDate;
  }
  </code></pre>
  
  <p>It would be really grateful if somebody can help</p>