Page 1 of 1
Add/substract months from date
Posted: Tue Sep 20, 2005 4:20 am
by sachinamr
I want to substract 3 moths from date field. I would appreciate if anyone tells me how do it.
Thanks in advance.
Posted: Tue Sep 20, 2005 4:39 am
by cmmurari
pls refer date function's in Parallel Job developer's guid page 1105
you can try DateFromDaysSince
regards,
krish
Posted: Tue Sep 20, 2005 5:31 am
by kumar_s
Hi,
When ever you forcast or go beyond the given date, make sure you handle leap year as well.
regards
kumar
Posted: Tue Sep 20, 2005 10:17 am
by srikanthd1978
Using the followiing
example:
OutPutDate = DateFromDaysSince(-90, Link.InputDate)..
but there needs to be more rigor wrapped around for the Month of Feb, as well as Leap Year calculation...
..another sure shot method is ..if u can extract this data from a DB, using a User Defined Query ( like using a TimestampDiff function or a dateDiff function on the DB side ), that way u can avoid using complex Xfm( using stage Variables) to take Leap Year and the Month of Feb into Consideration...
Posted: Tue Sep 20, 2005 12:35 pm
by als110
I handled it by converting the date into a julian day added or subtracted the 3 months (-90) then converting it back to the date format:
DateFromJulianDay((JulianDayFromDate(lnkStmOut.POL_SYS_KEY_DT) - 180))
Posted: Tue Sep 20, 2005 4:40 pm
by ray.wurlod
Of course, 3 months can be anywhere between 90 and 92 days. Other variations are possible if you're dealing with the years when "they" fiddled with the calendar. A more robust solution would manipulate the month number and, as a possible consequence, the year and day numbers.