3 Replies Latest reply on Sep 6, 2010 11:14 AM by Subeesh Arakkan

    Date + 6 days to have 1 week

    cyrus@adobe

      hello to all...

       

      i'm trying to figure out how to add date to the selected date.

      example, i choose 2010-8-9 then what i want is when i choose that date it will be added by 6 days

      so the output would be 2010-8-9 to 2010-8-15?

       

      i;m using datefield;

      the output will be passed to a textinput or something?.

       

      anyone know how to do it? thanks :

        • 1. Re: Date + 6 days to have 1 week
          jatin4rise

          I can give you the high level overview, if i was at your place.

           

          I would have converted date to string

          and do appropriate modifications

          and then convet back string to date?

           

          Below code is not exactly suitable for your requirement, but you will get an

          idea for converting date into string

           

          ////////////////////date to

          string///////////////////////////////////////////

           

                                 private function

          convertDateToString(date_cdts:Date):String    {

                          var year:String = new String(date_cdts.fullYear);

                          var month:String = "0"new String(date_cdts.month1);

                          trace(month);

                          trace(month.length);

                          if(month.length >2){

                              month = modifyDate(month);

                              //month = month.slice(1,3);

                          }

                          var day:String =  "0"+String(date_cdts.date);

                          trace(day);

                          if(day.length >2){

                              day = modifyDate(day);

                              //day = day.slice(1,3);

                          }

                          str_startDate = new String(year"-"month"-"day);

                          trace(str_startDate);

                          return new String(year"-"month"-"day);

                      }

           

          ////////////////////////////////////////////////////////////////////

           

                      // Converting String into Date

                          var obj_ToBeSendToPopUp:Object = new Object();

                          var defaultDateInPopUp:Date = new Date(1974, 10, 30, 1, 20);

                          defaultDateInPopUp.setFullYear(year);

                          defaultDateInPopUp.setMonth(Number(month)-1);

                          defaultDateInPopUp.setDate(day);

           

          //////////////////////////////////////////////////////////////////////////////////

           

          Hope my code ws helpful

          • 3. Re: Date + 6 days to have 1 week
            Subeesh Arakkan Level 4

            try date.hours = date.hours + 24 * no_of_days