how to get 30 days old date from current date

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Cherukuri
Participant
Posts: 46
Joined: Wed Jul 25, 2007 2:43 am
Location: India
Contact:

how to get 30 days old date from current date

Post by Cherukuri »

Hi,

Please help how to get 30 days old date from current date .

Thanks and Regards,
Cheru
bob7027
Participant
Posts: 22
Joined: Wed Oct 03, 2012 2:49 pm
Location: United States

Post by bob7027 »

do you need exact 30 days old date or every last month date..?
Cherukuri
Participant
Posts: 46
Joined: Wed Jul 25, 2007 2:43 am
Location: India
Contact:

Post by Cherukuri »

Thank you for the reply...

I want 30 days old date..

for example today is : 26-04-2013

output should be : 27-03-2013 (which is 30days old date)

Please help on this.
Cheru
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Look into the DateFromDaysSince() function, or if you are on 8.5+ there's DateOffsetByComponents() as well. Always a good idea to check the documentation first when you have a question like this. While there you'll also find functions like CurrentDate() or CurrentTimestamp() depending on what you need.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chandra.shekhar@tcs.com
Premium Member
Premium Member
Posts: 353
Joined: Mon Jan 17, 2011 5:03 am
Location: Mumbai, India

Post by chandra.shekhar@tcs.com »

As suggested by Craig,
for Datastage 8.5+

Code: Select all

DateOffsetByComponents(CurrentDate(),0,0,-30)
For Earlier versions of Datastage

Code: Select all

DateFromDaysSince(-30, CurrentDate())
Thanx and Regards,
ETL User
Cherukuri
Participant
Posts: 46
Joined: Wed Jul 25, 2007 2:43 am
Location: India
Contact:

Post by Cherukuri »

Thank you for your help and time.
Cheru
Post Reply