Multiple date format

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
shrey3a
Premium Member
Premium Member
Posts: 234
Joined: Sun Nov 21, 2004 10:41 pm

Multiple date format

Post by shrey3a »

Hi Gurus,

I've input date coming in all the different format , our requirement is to convert the date in YYYY-MM-DD format.

I tried using Iconv, Oconv combination but it fails at some point.
Wondering if there is any code available or I've tocreate a routine with case statement.

Thanks
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

What are all the possible formats? Can you provide a list. ICONV with Date option should work for most of them. Thats why I requested for a list of all formats so that the odd one out can be factored in.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
shrey3a
Premium Member
Premium Member
Posts: 234
Joined: Sun Nov 21, 2004 10:41 pm

Post by shrey3a »

YYYY-MM-DD
MM-DD-YYYY
DD-MM-YYYY
MM/DD/YYYY
DD/MM/YYYY

I need to check if its YYYY-MM-DD then ok otherwise conver it to YYYY-MM-DD

Regards
DSguru2B wrote:What are all the possible formats? Can you provide a list. ICONV with Date option should work for most of them. Thats why I requested for a list of all formats so that the odd one out can be factored in.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You will have to request for a consistent format. This is going to be a challenge as per programming. For example, how can you tell which part is day and which part is month in "01/01/2004". It could be either DD/MM/YYYY or MM/DD/YYYY.
You will have to either ask for a consistent date format per dataset.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Titto
Participant
Posts: 148
Joined: Tue Jun 21, 2005 7:49 am

Post by Titto »

I think if you know the number of distinct format then using iconv and if condition change the target format.
shrey3a
Premium Member
Premium Member
Posts: 234
Joined: Sun Nov 21, 2004 10:41 pm

Post by shrey3a »

That what I was trying to do nut not succesful as how can you tell Iconv function that its particular format if not then go to next condition.

It might be simple but not clicking to me :-(

Thanks
Titto wrote:I think if you know the number of distinct format then using iconv and if condition change the target format.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Its not do-able. I would love to be proven wrong. But its not possible. You tell me, what date is "09-05-2006"? Is it "9th of May, 2006" or "5th of September, 2006".
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

It's more possible than you imagine. :wink:

Check the sdk Date routine called 'DateGenerticToTimestamp', perhaps just use it directly or 'adapt' the code into your own routine.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

It's totally impossible if there's a mix of DD/MM/YY and MM/DD/YY because of the ambiguity inherent therein. Demand a consistent format or a format flag.
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