Date Comparision

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
pavan_test
Premium Member
Premium Member
Posts: 263
Joined: Fri Sep 23, 2005 6:49 am

Date Comparision

Post by pavan_test »

Hi All,

Can someone please suggest me how do solve this in datastage,

I have a create_date, start date and end date. End date is nullable. create date and start date are not nullable.

all 3 date columns are in the format mm/dd/yyyy (eg:7/24/2009)

if create_date is >= start_date and create_date <= end_date (if end date exists) then output data.

The create date and start date have to compared to the granular level i.e. month, date and year.

eg: create date can be 8/10/2011 and start date can be 8/9/2011. in this cate create date is greater than start date.

Thanks
Pavan
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The easiest way to work at this problem is to convert all 3 strings to dates - StringToDate(In.col,"%mm/%dd/%yyyy") and then you can do the ">" and "<" comparisons.
vamsi.4a6
Participant
Posts: 334
Joined: Sun Jan 22, 2012 7:06 am
Contact:

Post by vamsi.4a6 »

1)You can also use DaysSinceFromDate functions as below

If DaysSinceFromDate(create_date,start_date)>=0 and DaysSinceFromDate(end_date,create_date)>=0 then output data


Please correct me if I am wrong?
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

You would still need to convert to date so Arnd's would be better.

The only other bit would be to default the end date to a high value (e.g. 9999-12-31) to make the comparison easier (assuming a null means it hasn't ended...)
Post Reply