Page 1 of 1

Date Format Checking

Posted: Tue Jul 17, 2007 12:13 pm
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.

Posted: Tue Jul 17, 2007 12:28 pm
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.

Posted: Tue Jul 17, 2007 12:37 pm
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.

Posted: Tue Jul 17, 2007 12:54 pm
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.

Posted: Tue Jul 17, 2007 1:39 pm
by us1aslam1us
How about using IsValid function? Do a search...

Posted: Tue Jul 17, 2007 2:51 pm
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.

Re: Date Format Checking

Posted: Tue Jul 17, 2007 11:44 pm
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

Posted: Wed Jul 18, 2007 12:21 am
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.