Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Date Format


Hi

I have a list box which calculates Week days in a month for every week.

It is currently showing single digits for days 1 - 9.

2014-12-15_09-30-47.png

I would like these to show with double digits 02 - 09. How can I do this?

This is the script I use to generate the dates

Dual(if( month(WeekStart( RE_DAY) )<> month( RE_DAY), 1 , day(WeekStart( RE_DAY) ))
&' - '&
if( month(WeekEnd( RE_DAY) )<> month( RE_DAY), day(RE_DAY) , day(WeekEnd( RE_DAY) )),if( month(WeekStart( RE_DAY) )<> month( RE_DAY), 1 , day(WeekStart( RE_DAY) ))) AS Weeks

1 Solution

Accepted Solutions
MarcoWedel

Dual(num(if( month(WeekStart( RE_DAY) )<> month( RE_DAY), 1 , day(WeekStart( RE_DAY) )),'00')
&' - '&
Num(if( month(WeekEnd( RE_DAY) )<> month( RE_DAY), day(RE_DAY) , day(WeekEnd( RE_DAY) )),'00'),if(month(WeekStart( RE_DAY) )<> month( RE_DAY), 1 , day(WeekStart( RE_DAY) ))) AS Weeks

View solution in original post

11 Replies
ali_hijazi
Partner - Master II
Partner - Master II

num(day(WeekStart( RE_DAY) )),'00')

I can walk on water when it freezes
Not applicable
Author

Put in another condition: if(len(num(day(WeekStart(RE_DAY))))=1, '0'&num(day(WeekStart( RE_DAY) ))) or

if(num(day(WeekStart(RE_DAY)<10,'0'&num(day(WeekStart(RE_DAY))))

I hope it helped!

BR

T

saumyashah90
Specialist
Specialist

=

num(day(WeekStart(Data) ),'00')

Response to Ali is good with one correction of bracket.

num(day(WeekStart(RE_DAY)),'00')

Not applicable
Author

Hi

The above solutions do not work as desired. Would you mind maybe re-writing the full expression and adding your parts in it?

jagan
Luminary Alumni
Luminary Alumni

Hi,

Use

'01' instead of 1

and Num(day(WeekStart( RE_DAY) ), '00') instead of day(WeekStart( RE_DAY) )

=Dual(if( month(WeekStart( RE_DAY) )<> month( RE_DAY), '01' , Num(day(WeekStart( RE_DAY) ), '00'))

&' - '&

if( month(WeekEnd( RE_DAY) )<> month( RE_DAY), num(day(RE_DAY), '00') , Num(day(WeekEnd( RE_DAY) ), '00')),if( month(WeekStart( RE_DAY) )<>month( RE_DAY), '01' , Num(day(WeekStart( RE_DAY) ), '00')))

Hope this helps you.

Regards,

Jagan.

saumyashah90
Specialist
Specialist

Dual(if( month(WeekStart( RE_DAY) )<> month( RE_DAY), 1 , num(day(WeekStart( RE_DAY) ),'00'))
&' - '&
if( month(WeekEnd( RE_DAY) )<> month( RE_DAY), day(RE_DAY) , num(day(WeekEnd( RE_DAY) ),'00')),if( month(WeekStart( RE_DAY) )<>

month( RE_DAY), 1 , num(day(WeekStart( RE_DAY) ),'00'))) AS Weeks

Please check on the brackets properly

Not applicable
Author

Thanks! I have applied the above solution ansd it works, except it does not cater for te 1st of any month.

Why is that and how can I fix this?

2014-12-15_10-53-43.png

jagan
Luminary Alumni
Luminary Alumni

Hi,

Check this

Dual(if( month(WeekStart( RE_DAY) )<> month( RE_DAY), '01' , num(day(WeekStart( RE_DAY) ),'00'))
&' - '&
if( month(WeekEnd( RE_DAY) )<> month( RE_DAY), Num(day(RE_DAY), '00') , num(day(WeekEnd( RE_DAY) ),'00')),if( month(WeekStart(RE_DAY) )<>

month( RE_DAY), '01' , num(day(WeekStart( RE_DAY) ),'00'))) AS Weeks

Regards,

Jagan.

saumyashah90
Specialist
Specialist

As mohan said

Use this    month( RE_DAY), '01'   insted of month(RE_DAY),'1'