Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

Changing Date Format

Hello,

I would like some help with date formatting.

I am using this master calendar:

Temp:

Load num#([Date],'#') as NumericDate

RESIDENT [Dates];

MinMax:

LOAD Min(NumericDate) AS MinDate,

   Max(NumericDate) AS MaxDate

RESIDENT Temp;

LET vMinDate = Num(Peek('MinDate',0,'MinMax'));

LET vMaxDate = Num(Peek('MaxDate',0,'MinMax'));

MasterCalendar:

LOAD

text(num(MonthStart(Date($(vMinDate) + RecNo() - 1)))) AS [Date],

Year(Date($(vMinDate) + RecNo() - 1)) as [Year],

Month(Date($(vMinDate) + RecNo() - 1)) as [Month],

    ceil(month(Date($(vMinDate) + RecNo() - 1))/3) as Quarter,

Date(monthStart(Date($(vMinDate) + RecNo() - 1)), 'MMM-YYYY') AS [MonthYear]

AUTOGENERATE ($(vMaxDate) - $(vMinDate)+1);

DROP TABLE MinMax;

DROP TABLE Temp;

But my dates appear in the 40295, 42102 format.

Is there any changes I can make to my master calendar in order to ensure that it is in the DD/MM/YYYY format?

Best wishes,

Alison

1 Solution

Accepted Solutions
MVP
MVP

Re: Changing Date Format

Absolutely Alison,

what you need to do is make sure that after you do calculations with a date is that you wrap it in a Date() function to convert it back to date from the numerical basic date that you get after a calculation.

So for example in your script instead of doing:

    text(num(MonthStart(Date($(vMinDate) + RecNo() - 1)))) AS [Date],     

you should do something like this:

    Date(MonthStart($(vMinDate) + RecNo() - 1), 'DD/MM/YYYY) AS [Date]

4 Replies
MVP
MVP

Re: Changing Date Format

Absolutely Alison,

what you need to do is make sure that after you do calculations with a date is that you wrap it in a Date() function to convert it back to date from the numerical basic date that you get after a calculation.

So for example in your script instead of doing:

    text(num(MonthStart(Date($(vMinDate) + RecNo() - 1)))) AS [Date],     

you should do something like this:

    Date(MonthStart($(vMinDate) + RecNo() - 1), 'DD/MM/YYYY) AS [Date]

Not applicable

Re: Changing Date Format

Hi Petter,

Thank you for your response.

My dates have now become formatted in a variety of ways as you can see here:

Screenshot (86).png

Do you think that the issue lies in the raw data?

Not applicable

Re: Changing Date Format

I think the error does lie with the raw data. Thank you for your help.

MVP
MVP

Re: Changing Date Format

If you get various date formats in your raw data you can use the Date# interpretation function to convert them into real dates. Then you can get them all to be shown in a uniform date format.

Community Browser