06-09-2012 02:28 PM
Hi All,
I am performing the following logic for date decrease which is of the format 01 may 1989
ctimeMinus50Days = dateLong - 1L
* ((long) DateTimeUtilities.ONEDAY);
}
and for increase the logic is
ctimeMinus50Days = dateLong + 1L
* ((long) DateTimeUtilities.ONEDAY);
But when i try to increase the date its getting decreased alwasy whats wrong here
Solved! Go to Solution.
06-09-2012 06:17 PM
Note sure why you aren't just coding this
ctimeMinus50Days = dateLong - 1L
* ((long) DateTimeUtilities.ONEDAY);
as
ctimeMinus50Days = dateLong - ((long) DateTimeUtilities.ONEDAY);
Don't see why what you are dong isn't working. What snippet of code can you show us the results of, that proves it isn't working? Please make sure you just show us as small a section of code as possible, create a special test program if you have too.
BTW, this arithmetic may not work as you want over Daylight Saving Time changes, when days are perhaps 23 hours or 25 hours.
06-10-2012 06:17 AM
06-10-2012 08:06 AM
If this is solved, then please mark it as solved - see Instructions in Help link near the top.
"I did not get your last point about DST changes."
Say that today is the day that clocks go back and they go back 1 hour because of DST. Then there are 25 hours in the day, not 24. So you can't just add 24 hours.
I woould like to be proved wrong, but the only way I have found to accurately move forward by one day is to take a Calendar Object, set it to the start time, use DateTimeUtilities to zero the time (see the zeroCalendarTime() method), get the long time from the Calendar, add 36 hours, put this back into a Calendar Object, and then zero the time again. Then I have the next day. I think this will always work. I'd love someone to suggest an easier way.....