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.
Date Format Checking
Moderators: chulett, rschirm, roy
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.
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
"You can never have too many knives" -- Logan Nine Fingers
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.
-
- Charter Member
- Posts: 822
- Joined: Sat Sep 17, 2005 5:25 pm
- Location: USA
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Problem is that these dates are all valid, being early in the so-called Christian era.
The correct approach is to use pattern matching.before applying an IsValid() function.
The correct approach is to use pattern matching.
Code: Select all
InLink.TheDate Matches "3A' '1N' '4N" : @VM "3A' '2N' '4N"
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 36
- Joined: Mon Jul 16, 2007 3:37 am
- Location: USA
Re: Date Format Checking
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
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
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:
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.
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
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers