Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need help in converting Distorted Date

Hi all,

I have a Date like below, How could I convert into MM-DD-YYYY.

Inline image 2      Inline image 1

~

Walter

1 Solution

Accepted Solutions
swuehl
MVP
MVP

If your date field shows different formats (and this is what you called distorted), you can look into Alt() function to test different date formats:

Example from HELP:

alt(

date#( dat , 'YYYY/MM/DD' ),

date#( dat , 'MM/DD/YYYY' ),

date#( dat , 'MM/DD/YY' ),

'No valid date'

)

In general, have a look into

Why don’t my dates work?

View solution in original post

5 Replies
sunny_talwar

Images are not visible, would you be able to reattach?

The basic idea is to do something like this:

Date(Date#(DateField, 'YourCurrentFormatHere'), 'MM-DD-YYYY') as DateField

swuehl
MVP
MVP

If your date field shows different formats (and this is what you called distorted), you can look into Alt() function to test different date formats:

Example from HELP:

alt(

date#( dat , 'YYYY/MM/DD' ),

date#( dat , 'MM/DD/YYYY' ),

date#( dat , 'MM/DD/YY' ),

'No valid date'

)

In general, have a look into

Why don’t my dates work?

Not applicable
Author

There is some more data which is not shown in the image. Where you could find data as

2914

2421

Where i assumed it to be Feb 9th 2014 and Feb 4th 2021 but its not.

Thank you Swuehl.

Not applicable
Author

Your attachment in the original post did not work so I am just going to explain based on an example.

Before your load script.. Set the Date and Time formate as below :

SET DateFormat='MM/DD/YYYY';

SET TimestampFormat='MM/DD/YYYY h:mm:ss[.fff] TT';

And try below in your load script.


Date([Your Date Field])     AS     DateField

It works for me. It turns our client's Australian dates (DD/MM/YYYY) into American (MM/DD/YYYY)

swuehl
MVP
MVP

And how do you interpret

12212

January 22 2012 or December 2nd 2012?