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: 
DavidFoster1
Specialist
Specialist

Setting default number format in the script

Hi

Is it possible to set the default format for a date/number in the script instead of the document properties.

What I am trying to do is calculate the start of the month of a particular date and have that month start formatted as MMM-YY while still remaining as a date datatype (allows other formatting and implicit sorting).

I want to include this in a master calendar procedure so I would prefer to be able to script the formatting instead of manually amending it.

Thoughts?

1 Solution

Accepted Solutions
Clever_Anjos
Employee
Employee

There is a simple trick to do that

First you create a dummy table to format you field

Temp:

LOAD

    date(Today(),'MMM/YYYY') AS _month

AutoGenerate 1;

then you load you real data

yourrealtable:

LOAD

    rand() as field1,

    rand() as field2,

    monthstart(today() - RecNo()) as _month

AutoGenerate 100;

Then you can drop your dummy

Drop Table Temp;


QlikView seems to respect the format of first data loaded for a field

View solution in original post

3 Replies
Not applicable

Hello David,

You can set the default format in script by:

SET DateFormat='MMM-YY';

Is this what are you looking for?

DavidFoster1
Specialist
Specialist
Author

That is the universal option that applies to all dates in your model. I am looking for an option for individual fields.

Clever_Anjos
Employee
Employee

There is a simple trick to do that

First you create a dummy table to format you field

Temp:

LOAD

    date(Today(),'MMM/YYYY') AS _month

AutoGenerate 1;

then you load you real data

yourrealtable:

LOAD

    rand() as field1,

    rand() as field2,

    monthstart(today() - RecNo()) as _month

AutoGenerate 100;

Then you can drop your dummy

Drop Table Temp;


QlikView seems to respect the format of first data loaded for a field