Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
gnmq
Contributor III
Contributor III

Format date YYYYMMDD as "integer"

Hi,

 

I would like to check how can I convert a date field to an integer field?

For example, formatting date "20190131" AS integer "20190131"

 

The original date format is date-time, and I have formatted it with "Date" function to extract the date in format "YYYYMMDD".

Load 

Date(EffectiveDate, 'YYYYMMDD') as Date_Key

Resident TableA;

 

Updated solution:

=> Convert Date to Text then Integer

Load 

Num#(TEXT(Date(EffectiveDate, 'YYYYMMDD'))) as Date_Key

Resident TableA;

 

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

I am not sure why you would wan to do this, but probably:

Num(Text(Date(EffectiveDate, 'YYYYMMDD'))) as Date_Key

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

5 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

I am not sure why you would wan to do this, but probably:

Num(Text(Date(EffectiveDate, 'YYYYMMDD'))) as Date_Key

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
gnmq
Contributor III
Contributor III
Author

Hi, thanks for the reply. I tested your method but it didn't work.

The output returns blank instead.

NUM(TEXT(DATE(EFFECTIVE_DATE,'YYYYMMDD'))) AS DATE_KEY

TEST1.PNG

 

 

gnmq
Contributor III
Contributor III
Author

Hi Jonty,

 

I retested your method with num#() and it works! Thanks so much 🙂

jonathandienst
Partner - Champion III
Partner - Champion III

You  are absolutely correct - my bad.😀

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
mkamal
Contributor III
Contributor III

I thought Num# was for interpreting and Num was for changing a format.  So why does Num# work in this case and Num does not?