Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
rahulramanm
Contributor II
Contributor II

Date format in if condition

Hi,

I am trying to filter data based on date. I am using if statement here.

Code:

if(day(max(DATEFIELD))>'25','25/'&month(max(DATEFIELD))&'/'&year(max(DATEFIELD)),max(DATEFIELD))

The else part should return date in 'DD/MM/YYYY' format, but it's returning the date's floor value. I need the code to return the date in 'DD/MM/YYYY' format.

Please help.

2 Solutions

Accepted Solutions
Lauri
Specialist
Specialist

Maybe the second part of your If statement needs to be explicitly a date (with makedate) instead of text:

date(if(day(max(DATEFIELD))>'25', makedate(year(max(DATEFIELD)), month(max(DATEFIELD)), 25), max(DATEFIELD)), 'MM/DD/YYYY')

View solution in original post

sasiparupudi1
Master III
Master III

may be try

if(day(max(DATEFIELD))>'25',

MakeDate(year(max(DATEFIELD)),month(max(DATEFIELD)),25),

 ,max(DATEFIELD))

View solution in original post

6 Replies
Lauri
Specialist
Specialist

Try formatting the else part:

date(max(DATEFIELD), 'DD/MM/YYYY')

rahulramanm
Contributor II
Contributor II
Author

Already tried this, not working. 😞

Lauri
Specialist
Specialist

Maybe the second part of your If statement needs to be explicitly a date (with makedate) instead of text:

date(if(day(max(DATEFIELD))>'25', makedate(year(max(DATEFIELD)), month(max(DATEFIELD)), 25), max(DATEFIELD)), 'MM/DD/YYYY')

sasiparupudi1
Master III
Master III

may be try

if(day(max(DATEFIELD))>'25',

MakeDate(year(max(DATEFIELD)),month(max(DATEFIELD)),25),

 ,max(DATEFIELD))

rahulramanm
Contributor II
Contributor II
Author

Thanks Sasi,

Just a change in code : Makedate has to be formatted to 'DD/MM/YYYY' in my case.

rahulramanm
Contributor II
Contributor II
Author

Thanks Laurischarf,

Just a change in code : Makedate has to be formatted to 'DD/MM/YYYY' in my case.