Get Date

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
cyclogenisis
Premium Member
Premium Member
Posts: 48
Joined: Wed Jan 07, 2015 3:30 pm

Get Date

Post by cyclogenisis »

Hello,

Trying to get the date of the most recent Sunday that has past (or if it is Sunday use that date). Deriving this date in a user variable stage.

Would like the output format of the date to be YYYYMMDD.

thanks!
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Try using the PreviousWeekdayFromDate() function. Let us know what you try and if you get stuck.
Choose a job you love, and you will never have to work a day in your life. - Confucius
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Try this.

Code: Select all

Oconv(Date() - Mod(Date(),7), "DYMD[4,2,2]" : @VM : "MCN")
The internal format of the date is an integer. Assuming your system is set up with Sunday = 0, the first argument of the Oconv() function above will give the date of the most recent Sunday.
If your system is set up with a different day as the first of the week, simply adjust the arithmetic to suit.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Try using the PreviousWeekdayFromDate() function. Let us know what you try and if you get stuck.
Choose a job you love, and you will never have to work a day in your life. - Confucius
qt_ky
Premium Member
Premium Member
Posts: 2895
Joined: Wed Aug 03, 2011 6:16 am
Location: USA

Post by qt_ky »

Ah, I saw the "parallel" type and missed the user variables stage part.
Choose a job you love, and you will never have to work a day in your life. - Confucius
cyclogenisis
Premium Member
Premium Member
Posts: 48
Joined: Wed Jan 07, 2015 3:30 pm

Post by cyclogenisis »

thanks ray
Post Reply