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

Announcements
FLASH SALE: Save $500! Use code FLASH2026 at checkout until Feb 14th at 11:59PM ET. Register Now!
cancel
Showing results for 
Search instead for 
Did you mean: 
vireshkolagimat
Creator III
Creator III

Master Calendar

Hi All,

I got the below script while creating the master calendar. Could somebody please explain it.

On what basis we taking the multiplier. Year is multiplied by 1000 and month by 100 & day nothing.

Year(Temp_Date) * 10000 + Month(Temp_Date) * 100 + Day(Temp_Date)  as [DateKey],

Regards,

Viresh

1 Solution

Accepted Solutions
swuehl
Champion III
Champion III

Day shows at max 2 digits, month shows at max 2 digits.

So by multiplying Month with 100 and Year with 100*100, you ensure that Year, Month and Day values keep seperated when adding up the values, to ensure that each DateKey value represents an unambiguous Date value.

View solution in original post

5 Replies
Frank_Hartmann
Master II
Master II

actually you are just determining the digits of your datefield  by multiplying.

e.g.

Year(Now()) * 10000 =  2017 * 1000        = 20170000

Month(Now()) * 100  = 08 * 100               = 0800

Day(Now())                                               = 20


20170000 + 0800 + 20 = 20170820

swuehl
Champion III
Champion III

Day shows at max 2 digits, month shows at max 2 digits.

So by multiplying Month with 100 and Year with 100*100, you ensure that Year, Month and Day values keep seperated when adding up the values, to ensure that each DateKey value represents an unambiguous Date value.

effinty2112
Master
Master

Hi Viresh,

This script will create dates in the format YYYYMMDD.

20th Aug 2017

Year(20th Aug 2017)*10000 =      20170000

Month(20th Aug 2017)*100 =                 800

Day(20th Aug 2017) =                               20

                                                       20170820

Cheers

Andrew

swuehl
Champion III
Champion III

You should be able to alternatively use

Num#(Date([Temp_Date],'YYYYMMDD')) as [DateKey]

You need the Num#() to not only format the text representation of the temp date as desired, but to create a numeric value that matches the format.

QlikView Date fields

vireshkolagimat
Creator III
Creator III
Author

Hi Stefan,

thanks for the clarification.

Regards,

Viresh