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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Make Calendar with 001 and 2012

Hi, from our BW, our months and years roll out in the following format :

FMonth = 001

FYear = 2012

Now, based on that, I want to build my calendar, but somehow it doesn't work with the following code :

LOAD Distinct

     FYear,

     FMonth,

     MakeDate(Num(FYear), Num(Mid(FMonth,2,2),1) as TempDate,

     Date#(TempDate,'YYMM') as OrderDate

Resident Orders;

What do i do wrong?

Thanks

1 Solution

Accepted Solutions
Not applicable
Author

Hi

You have a couple of issues but the main one is that you can't create the field TempDate and use it to create OrderDate in the same preceeding load. You are also trying to use the date#() function to format the date which it doesn't do. date#() creates a date from a string following the given format. Your makedate() already creates a valid date and so you simply need to use the date() function to format it rather than the date#() function.

Assuming you don't want TempDate in your final table, try the below code instead:

LOAD DISTINCT

     FYear,

     FMonth,

     date(makedate(num(FYear),num(FMonth,'00')),'YYMM') AS OrderDate;

Resident Orders;

Hope that makes sense

Matt

View solution in original post

3 Replies
Not applicable
Author

Hi

You have a couple of issues but the main one is that you can't create the field TempDate and use it to create OrderDate in the same preceeding load. You are also trying to use the date#() function to format the date which it doesn't do. date#() creates a date from a string following the given format. Your makedate() already creates a valid date and so you simply need to use the date() function to format it rather than the date#() function.

Assuming you don't want TempDate in your final table, try the below code instead:

LOAD DISTINCT

     FYear,

     FMonth,

     date(makedate(num(FYear),num(FMonth,'00')),'YYMM') AS OrderDate;

Resident Orders;

Hope that makes sense

Matt

CELAMBARASAN
Partner - Champion
Partner - Champion

Hi,

     Simply use

    

LOAD DISTINCT

     FYear,

     FMonth,

     makedate(num(FYear),num(FMonth,'00')) AS OrderDate

Resident Orders;

Celambarasan

Not applicable
Author

thanks guys