Validating Date

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

G SHIVARANJANI
Participant
Posts: 137
Joined: Sun Jan 07, 2007 11:17 pm
Location: VISAKHAPATNAM

Validating Date

Post by G SHIVARANJANI »

Hi,

Could any one help me out in validating a date column of a CSV file .

the date format in the column is mm/dd/yyyy......

and i need to validate the date if it is a valid date or not.


thanks,
Shivaranjani
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Use the IsValid() function. Find it in the Parallel Job Developer's Guide
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
JoshGeorge
Participant
Posts: 612
Joined: Thu May 03, 2007 4:59 am
Location: Melbourne

Post by JoshGeorge »

Use IsValid() function.
If your input date is not in date format you might want to convert it and use - IsValid('date',StringToDate(InputLink.Date,"%yyyy%mm%dd"))
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
G SHIVARANJANI
Participant
Posts: 137
Joined: Sun Jan 07, 2007 11:17 pm
Location: VISAKHAPATNAM

Post by G SHIVARANJANI »

I am reading the date column as varchar but not as date, then will this syntax work IsValid('date',StringToDate(InputLink.Date,"%yyyy%mm%dd"))










JoshGeorge wrote:Use IsValid() function.
If your input date is not in date format you might want to convert it and use - IsValid('date',StringToDate(InputLink.Date,"%yyyy%mm%dd"))
Shivaranjani
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Try it and see. Correct the date mask so it matches what you've said is in your file first, however.
-craig

"You can never have too many knives" -- Logan Nine Fingers
G SHIVARANJANI
Participant
Posts: 137
Joined: Sun Jan 07, 2007 11:17 pm
Location: VISAKHAPATNAM

Post by G SHIVARANJANI »

Hi,

Isvalid is giving 0 for all the dates



this 12/34/2006 as well as this 01/01/2006
:cry:
Shivaranjani
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Because, as noted, the mask in the supplied example does not match your input format.
-craig

"You can never have too many knives" -- Logan Nine Fingers
G SHIVARANJANI
Participant
Posts: 137
Joined: Sun Jan 07, 2007 11:17 pm
Location: VISAKHAPATNAM

Post by G SHIVARANJANI »

chulett wrote:Because, as noted, the mask in the supplied example does not match your input format. ...
i have given the mask as %mm/%dd/%yyyy
Shivaranjani
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Get rid of the slashes.
-craig

"You can never have too many knives" -- Logan Nine Fingers
G SHIVARANJANI
Participant
Posts: 137
Joined: Sun Jan 07, 2007 11:17 pm
Location: VISAKHAPATNAM

Post by G SHIVARANJANI »

yes must be because 1/1/2006 dint match with mm/dd/yyyy

right?


chulett wrote:Get rid of the slashes. ...
Shivaranjani
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

No.

Does 'yes' mean it is working for you now? If so, please mark the thread as Resolved. If not, please explain what issue remains.
-craig

"You can never have too many knives" -- Logan Nine Fingers
G SHIVARANJANI
Participant
Posts: 137
Joined: Sun Jan 07, 2007 11:17 pm
Location: VISAKHAPATNAM

Post by G SHIVARANJANI »

Hi,

Since i am gettin the dates as d/m/yyyy its not matching with the mask dd/mm/yyyy....

so i have picked up the d and padded it with 0 so that it matches dd and the same way for month as well.

Thanks for the help its working.





chulett wrote:No.

Does 'yes' mean it is working for you now? If so, please mark the thread as Resolved. If not, please explain what issue remains. ...
Shivaranjani
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Yea, but make sure you include a check before padding it with zero. What if the month is 11 or 12 and the day is two digits as well?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Why not use three IsValid() functions (with different date format strings) connected by OR ?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
G SHIVARANJANI
Participant
Posts: 137
Joined: Sun Jan 07, 2007 11:17 pm
Location: VISAKHAPATNAM

Post by G SHIVARANJANI »

I have put the settings of:

In my PC:

control pannel<enter>

regional and language options<enter>

customiz<enter>

Date<enter>

Short date format<enter>


as MM/DD/YYYY.

this is making the Datastage sequential file to read in DD/MM/YYYY instead of D/M/YYYY.
Shivaranjani
Post Reply