Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
qliky88
Creator
Creator

Change column format from General to Date

Hi Experts, 

 

I have a column in my data set that Qlik has recognized as General, however I want to convert it to Date. 

 

The column is in MMM/DD/YYYY hh:mm:tt (e.g. Apr 4 2008 4:00AM) and I want to convert it to DD/MMM/YYYY format. Have tried a few variations of the screenshot attached but to no avail. Any ideas where I'm going wrong? Should I be converting it in the load script? 

jakeQlik_0-1598964669561.png

 

Thanks 🙂

Labels (2)
2 Solutions

Accepted Solutions
Kushal_Chawda

Best way to handle this problem is to change the format of the field at database end itself to have a unique format for all the values. If it is not possible then you need to identify all the unique format exists in all the field values and use the alt function to change format for each

Let's assume you identified below two formats in your data

'MMM D YYYY hh:mmTT' ,'DD.MM.YYYY hh:mmTT'

then you can below logic in qlik to convert

date(floor(alt(timestamp#(Date,'MMM D YYYY hh:mmTT'),timestamp#(Date,'DD.MM.YYYY hh:mmTT'))),'DD/MMM/YYYY') as Date

View solution in original post

qliky88
Creator
Creator
Author

Hi @Kushal_Chawda 

Just for the record a solution was eventually arrived at. Hopefully the below formula may help anyone in the future 🙂 

 

Date(makedate(num(If(num(subfield("datefield",' ',3))<10, subfield("datefield",' ',4), subfield("datefield",' ',3))), sum(month(date#(subfield("datefield",' ',1),'MMM'))), num(If(subfield("datefield",' ',2)='', subfield("datefield",' ',3),subfield("datefield",' ',2)))) ,'DD MMM YYYY') as NewDateField

View solution in original post

14 Replies
Kushal_Chawda

@qliky88  Can you show screenshot of few values?

qliky88
Creator
Creator
Author

Hi @Kushal_Chawda thanks for your help with this. See attached 

 

jakeQlik_0-1598967181070.png

 

 

Usama
Creator
Creator

Hi,
Try this:
Date(Date,'DD/MMM/YYYY') as Upd_date

Thanks,
Usama

From Nothing - To Something - To Everything
arulsettu
Master III
Master III

Maybe like this

Date(Date#('Mar 25 2008 4:00AM','MMM DD YYYY hh:mmtt'),'MMM/DD/YYYY')

Kushal_Chawda

try below

=date(floor(timestamp#(Date,'MMM D YYYY hh:mmTT')),'DD/MMM/YYYY')

qliky88
Creator
Creator
Author

Thanks everyone for their replies, 

@Kushal_Chawda  was the closest to getting it. I inserted your formula into the load script but it seems to now only return one date?! 

Very unusual error if anyone could point me in the right direction I would really appreciate it ! 

dates.png

Kushal_Chawda

@qliky88 

Assuming you have put down the formula in load script correctly. If so I don't think any chances of getting error. It might be that all time field values don't have same format due to which only few are getting converted

LOAD *,

          date(floor(timestamp#(YourTimeField,'MMM D YYYY hh:mmTT')),'DD/MMM/YYYY') as Date

FROM table;

 

qliky88
Creator
Creator
Author

@Kushal_Chawda 

 

See below. Its a tricky one 😛 If I resolve I will post any updates here. Thanks everyone 🙂 

 

jakeQlik_0-1599041949311.png

 

Kushal_Chawda

@qliky88  Can you check that CAPA_CLOSE_DATE coming from source has same format for all values ?