Qlik Community

Ask a Question

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Talk to Experts Tuesday, January 26th at 10AM EST: Qlik Sense. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Creator III
Creator III

Date conversion

Hi,

I had a date field with values like this: '01-02-2016' and i want to make the value a format like this: '41640'.

How to convert the date value to a number like this?

Any help!

Thanks,

ahmed100

1 Solution

Accepted Solutions

Num(Date#( '01-02-2016' ,'MM-DD-YYYY'))

regards

Marco

View solution in original post

12 Replies

Num(Date#( '01-02-2016' ,'MM-DD-YYYY'))

regards

Marco

View solution in original post

Creator III
Creator III

Thanks Marco!

Regards,

Ahmed100

MVP & Luminary
MVP & Luminary

HI,

Try like this

LOAD

*,

Num(Date#( DateFieldName ,'MM-DD-YYYY')) AS DateFieldName_Number

FROM DAtaSource;


If above not working then try this

LOAD

*,

Num(DateFieldName) AS DateFieldName_Number

FROM DAtaSource;


Hope this helps you.


Regards,

Jagan.

Creator III
Creator III

Hi Jagan,

I also have two other conversion to take care:

1.  Convert Date field format '01-02-2016'  to '01/02/2016' format and

2. Convert Date field format '41640'  to '01/02/2016' format

Thanks in advance.

Regards,

ahmed100

MVP & Luminary
MVP & Luminary

HI,

Try like this using Alt() if both dates are in single column

LOAD

*,

Date(Alt(Date#(FieldName, 'MM-DD-YYYY'), FieldName) AS NewField

FROM DataSource;

Regards,

Jagan.

Creator III
Creator III

Hi Jagan,

Thanks for your reply. But They are different fields.

Regards,

ahmed100

MVP & Luminary
MVP & Luminary

HI,

Then try like this separately

Date(Date#(FieldName1, 'MM-DD-YYYY'))

Date(FieldName2)

Regards,

Jagan.

Creator III
Creator III

Hi Jagan,

Could you show me, how To convert date format '41640' to date format 'YYYY-MM-DD' ?

Thanks,

ahmed100

MVP & Luminary
MVP & Luminary

Date(FieldName2, 'YYYY-MM-DD')


Regards,

Jagan.