Date Format Checking

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
rajkraj
Premium Member
Premium Member
Posts: 98
Joined: Wed Jun 15, 2005 1:41 pm

Date Format Checking

Post by rajkraj »

Is there any method for checking the date format (particularly year) in datastage?

I am getting some dates in source before I load into target I need to check is that date is correct format?

for ex: I am getting some dates like below:
Nov 30 200
Jan 1 175
Dec 21 200

Year is not coming properly.

I've searched for it and found
Write a routine (checkDate) with two arguments - dateString, dateFormat

Code:

tmp = IConv(dateString,dateFormat)
Ans = Status()
[/b]

But it is not working for year.

Is there any method/way to check this.

Thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I'm guessing your issue is the fact that you would want your three example dates to be declared 'invalid' - the problem is they are perfectly valid dates.

Seems like you'd need to do any standard date checks you currently are doing and then add in a 'range check' for the year - a business rule that says the years must be no less than X, for example. Whatever makes sense.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rajkraj
Premium Member
Premium Member
Posts: 98
Joined: Wed Jun 15, 2005 1:41 pm

Post by rajkraj »

Yes, I want to declare 'Invalid' for this type of date formates.
chulett wrote:I'm guessing your issue is the fact that you would want your three example dates to be declared 'invalid' - the problem is they are perfectly valid dates.

Seems like you'd need to do any standard date checks you currently are doing and then add in a 'range check' for the year - a business rule that says the years must be no less than X, for example. Whatever makes sense.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ok, go ahead then. :wink:

If you've tried already and it's "not working" let us know what you've tried and what about it isn't behaving the way you want.
-craig

"You can never have too many knives" -- Logan Nine Fingers
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

How about using IsValid function? Do a search...
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Problem is that these dates are all valid, being early in the so-called Christian era.
The correct approach is to use pattern matching.

Code: Select all

InLink.TheDate Matches "3A' '1N' '4N" : @VM "3A' '2N' '4N" 
before applying an IsValid() function.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
reddy.vinod
Participant
Posts: 36
Joined: Mon Jul 16, 2007 3:37 am
Location: USA

Re: Date Format Checking

Post by reddy.vinod »

Hi rajkraj,
I think u have to use "oconv" function.if u have two dates in different formats , so u first use oconv function and get the dates internal format then u use iconv function.this will give the correct answer,i tried
VINOD
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Vinod, you've got your 'conv' functions backwards. Ray's check will ensure (amongst other things) that the year portion of your dates are four digits. If that's good enough, go for it. If you need a tighter check than that, that the year falls within a certain range, then you'll need to check the year separately.

One such way could be to use Field() to get the year and check it is at least a certain value. A brain-dead example:

Code: Select all

Field(Source.Date," ",3) > 1950
You'd need to determine what a 'valid' range would be and if you'd need to check both 'directions', i.e. future dates as well.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply