Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
BoXiangWang
Contributor II
Contributor II

Change Date Format in Variable Input

Hi all QS expert,

I want to know if it's possible to change the format in variable input.

I have a field named [aggr_date_month] and it's a date field. It shows the start_date of each month. For instance, 2024-01-01.

In the variable input, I have this expression:
Concat(distinct {<[aggr_date_month]={"<=$(=MonthStart(AddMonths(Today(),-1)))"}>} [aggr_date_month], '|', -[aggr_date_month])

So I can show each month from last month until the oldest month in my dataset.

 

The variable I set is vStartDate and the expression is:

=YearStart(AddYears(Today(),0))

 

Now I am asked to show the date in 'YYYY-MMM' format. For instance, 2024-01-01 should be 2024-Jan. I tried several ways but couldn't manage it.

Such as:

=Concat(distinct{<[aggr_date_month]={"<=$(=Date(MonthStart(AddMonths(Today(),-1)),'YYYY-MM-DD'))"}>} Date([aggr_date_month],'YYYY-MMM'), '|', -Date([aggr_date_month],'YYYY-MMM'))

I want to ask for advices from your knowledge if there is a way to make it happen. Thanks!

 

Labels (2)
1 Reply
MarkK11
Contributor
Contributor

Hi,

To change the date format in Qlik Sense to ‘YYYY-MMM’, you can use the Date function with the appropriate format string. Your expression should look like this:

=Concat(distinct {<[aggr_date_month]={"<=$(=MonthStart(AddMonths(Today(),-1)))"}>} 
Date([aggr_date_month], 'YYYY-MMM'), '|')

This will convert your dates into the desired format, showing the year and the abbreviated month.


Best regard,
PublixPassport