Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Text to date format in script

Hi ,

Can anyone help me in getting the year?

I tried the below script but it not working ... 

ABC:

LOAD Date#(Date)as Date,,

          Year(Date#(Date)) as year,  

          Name,      

          Product,      

Sales FROM CORE_DUP\123.txt (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

5 Replies
swuehl
MVP
MVP

Have you tried with the correct date format?

SET DateFormat = 'M/D/YYYY';

ABC:

LOAD Date#(Date) as Date,

          Year(Date#(Date)) as year,  

          Name,      

          Product,      

Sales FROM CORE_DUP\123.txt (txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

Anonymous
Not applicable
Author

Thanks Stefan,

PrashantSangle

Hi,

try like

date(date#(Date,'M/D/YYYY'))

Regards,

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Anonymous
Not applicable
Author

Hi,

If you tried the above script then you need to remove double "," from your script

As per your script itself you can able to get the year.

Please find the below script(Removed only the ,)

ABC:

LOAD Date#(Date)as Date,

          Year(Date#(Date)) as year, 

          Name,     

          Product,     

Sales

FROM

[123.txt]

(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

qlikview979
Specialist
Specialist

Hi Try  like this

LOAD

Date(Date#(Date,'MM/DD/YYYY'),'DD/MM/YYYY') as Date1,

     Name,

     Product,

     Sales

FROM

(txt, codepage is 1252, embedded labels, delimiter is '\t', msq);

Regards