jshanks
22nd December 2006, 22:42
Hi All,
Is there a way to calculate forward date using utc.num()+number of days?

For e.g. I tried using utc.num()+12 but it returns just the current date and doesn't add 12 days to it. After searching the forums, I found some ways to seperate out the month, day and year and then recalculate the date but it has some limitations. I was wondering whether there is a easy way out to add 12 days to current date and store it in a utc type variable.

Any information will be greatly appreciated.
Regards
Jai

jshanks
22nd December 2006, 23:53
OK. I found one alternative. This is how I am calculating it for now.

domain tcdate tmpdate
long l_days, l_time, ret

ret = utc.to.local(utc.num(), l_days, l_time)
l_days = l_days + 12
ret = local.to.utc(l_days, l_time, tmpdate)

So, today's date 12/22/2006 + 12 gave me 01/03/2007 which is the correct result.

If there is any other easier way, please do let me know.

Thanks
Jai

bigjack
26th December 2006, 06:15
hi,

UTC format stores the total no. of seconds since 01/01/1970 , you can simply add the seonds i.e. (no. of days you want to add)*24(hrs)*60(mins)*60(secs).
In all probabilities it should work, let me know if it doesnt.

Bye

en@frrom
27th December 2006, 10:49
Like Bigjack said, you can always add nr_of_days * 86400.. This works fine

jshanks
3rd January 2007, 00:36
Thanks guys!! Works great.

Thanks
Jai