EASY way to add n days to a date?

zryip theSlug zryip.theslug at gmail.com
Sat Dec 19 19:40:12 EST 2009

A conversion function really handy!

Not totally in the subject:
An easy trick to know the end date of one month without creating
complex script to test the number of days in the months, years
leap, etc..
Take the first date of the month, then add one month and substract one
day, like this :

on mouseUp
   put "12/01/2009" into lMyDate
   answer addToDate(lMyDate,0,1,-1)
end mouseUp

function addToDate pStartDate,pAddToYear,pAddToMonth,pAddToDay
   convert pStartDate to dateitems
   add pAddToYear to item 1 of pStartDate
   add pAddToMonth to item 2 of pStartDate
   add pAddToDay to item 3 of pStartDate
   convert pStartDate to short date
   return pStartDate
end addToDate

-Zryip TheSlug wish you the best ! 8)

> convert tDate to dateitems
> add numDays to item 3 of tDate
> convert tDate to short date -- or other format
> The nice thing about the convert command is that you can add any number of
> days and it will figure out the right date anyway, changing the month and/or
> year as necessary.
> --
> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

More information about the Use-livecode mailing list