How to compare two dates in DS format SQL.SMALLDATETIME

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
snassimr
Premium Member
Premium Member
Posts: 281
Joined: Tue May 17, 2005 5:27 am

How to compare two dates in DS format SQL.SMALLDATETIME

Post by snassimr »

I want ot compare to dates 1999/01/02 and 2000/01/02 and the answer that i get is wrong
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

snassimr,

please explain how you are comparing them? If you do a "1999/02/02" = "2000/01/02" you are going to a get a 0 {wrong}. What are you trying to compare - their equality? Days between?
snassimr
Premium Member
Premium Member
Posts: 281
Joined: Tue May 17, 2005 5:27 am

Post by snassimr »

I want to get that '2000/01/01' is greater (later) then '1999/01/01'
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Since the format is yyyy/mm/dd you can do a simple string comparison, so your result of doing a ( '2000/01/01' > '1999/01/01' ) will return true. What is the condition you are testing - so that we might see why you state that it is wrong...
Sainath.Srinivasan
Participant
Posts: 3337
Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom

Post by Sainath.Srinivasan »

Make sure the format is yyyy/mm/dd. Also check you have 4 digit year.
amsh76
Charter Member
Charter Member
Posts: 118
Joined: Wed Mar 10, 2004 10:58 pm

Post by amsh76 »

Or you can convert them in DS internal format and then do the comparison.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Or you can use the Compare() function and enforce left-justified comparison of the original strings. Make sure that each has the same delimiter character.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply