Page 1 of 1

Multiple date format

Posted: Fri May 04, 2007 10:10 am
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

Posted: Fri May 04, 2007 10:19 am
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.

Posted: Fri May 04, 2007 10:23 am
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.

Posted: Fri May 04, 2007 10:37 am
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.

Posted: Fri May 04, 2007 10:53 am
by Titto
I think if you know the number of distinct format then using iconv and if condition change the target format.

Posted: Fri May 04, 2007 11:00 am
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.

Posted: Fri May 04, 2007 12:54 pm
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".

Posted: Fri May 04, 2007 2:46 pm
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.

Posted: Fri May 04, 2007 3:47 pm
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.