Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
pgalvezt
Specialist
Specialist

Trouble with format dates

Hi, I have 2 dates ActualDate and LastDate. With both dates i want to get an incremental reload with Qvds Files. Until now everything is fine but, in my access data appear ActualDate with 2 formats example: 21/03/2011 -> March 21(this is the correct format) and the other one 04-06-2011 -> June 04, Ithink Should be April 06(I think we are not at this time ). How can I get that QlikView read 04/06/2011-> April 06?

Thanks,

1 Solution

Accepted Solutions
Not applicable

It can't be. Please look into attached example.

Load script looks like this:

Test:

LOAD * INLINE [

    DATA

    05-20-2011

    20/06/2011

];

Test2:

load

          IF( SubStringCount(DATA, '-')> 0,

               DATE(DATE#(DATA,'MM-DD-YYYY'),'MMMM DD'),

               DATE(DATE#(DATA,'DD/MM/YYYY'),'MMMM DD'))      as DataActual

resident Test;             

View solution in original post

11 Replies
nagaiank
Specialist III
Specialist III

Try using Date# function with the format code MM/DD/YYYY.

e.g. Date#(datestring, 'MM/DD/YYYY')

pgalvezt
Specialist
Specialist
Author

Thank you for your replying. I have this:

LOAD

DATA,

date(DATA,'DD/MM/YYYY') as DataActual,

DATA1,

date(DATA1,'DD/MM/YYYY') as DataLast

FROM Excel File;

This shows me no values for DATA because here the format changed.

For DATA1 Shows me the right format.

Avy idea?

erichshiino
Partner - Master
Partner - Master

If you get this 04/06/2011 how do you know which date is it?

What about 02/03/2011? Is it 02-mar-2011 or 03-feb-2011?

You could write something like this:

if( isnum( date#(DATA,'DD/MM/YYYY') ),

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

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

  as DataActual


This code will try to apply the first format, if it's not a valid date, applies the second format.

You will still need a rule to really understand which is the right format

Regards,

Erich

pgalvezt
Specialist
Specialist
Author

Then reloading with the update script I had this: For data I know that / format its ok D/MM/YYYY but - Format its MM/DD/YYYY.

For data 1 everything its ok.

Any Idea?

Dates1.JPG

erichshiino
Partner - Master
Partner - Master

HI,

Lets include another condition. If it finds a - it will use another format

IF( SubStringCount(DATA, '-')> 0, DATE#(DATA, 'MM-DD-YYYY') ,

if( isnum( date#(DATA,'DD/MM/YYYY') ),

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

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

)

  as DataActual

edit: just removed a line with an error

pgalvezt
Specialist
Specialist
Author

Hi, I try this:

IF( SubStringCount(DATA, '-')> 0,

     DATE#(DATA,'MM-DD-YYYY'),

date#(DATA,'DD/MM/YYYY')) as DataActual,

But still can´t find the solution.

I´ve Attached the datasource where you can see the different format in column DATA.

ARC1.JPG

Not applicable

Try this:

IF( SubStringCount(DATA, '-')> 0,

     DATE(DATE#(DATA,'MM-DD-YYYY'),'MMMM DD'),

     DATE(DATE#(DATA,'DD/MM/YYYY'),'MMMM DD'))      as DataActual,

Regards,

Janusz

pgalvezt
Specialist
Specialist
Author

Hi Janusz, Thanks for you answer but I still have the same Issue. The results that shows before still appearing of the same form.

Not applicable

It can't be. Please look into attached example.

Load script looks like this:

Test:

LOAD * INLINE [

    DATA

    05-20-2011

    20/06/2011

];

Test2:

load

          IF( SubStringCount(DATA, '-')> 0,

               DATE(DATE#(DATA,'MM-DD-YYYY'),'MMMM DD'),

               DATE(DATE#(DATA,'DD/MM/YYYY'),'MMMM DD'))      as DataActual

resident Test;