Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
TheresaB_4
Contributor III
Contributor III

Greater than and smaller than date functions

Good morning everyone.

I need to select a contract End date selection in Qlik. 

I have this, but it is not selecting the dates correct, maybe I need to format the string as well. Not sure how to do this.

=if(date(EndDateFullDate)>date('01-05-2023')and date(EndDateFullDate)<date('31-12-2023'),'yes','no')

It does not work between those dates. Any suggestions

Labels (3)
2 Solutions

Accepted Solutions
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

 

You can try Date#() function:

 

=if(date(EndDateFullDate)>date#('01-05-2023', 'DD-MM-YYYY') and date(EndDateFullDate)<date#('31-12-2023', 'DD-MM-YYYY'),'yes','no')

Help users find answers! Don't forget to mark a solution that worked for you!

View solution in original post

steeefan
Luminary
Luminary

Convert that int to a date, then compare:

 

If(Date#(EndDateKey, 'YYYYMMDD') > Now(), 'Expired', 'Active') AS Contract_Status

 

Also, if EndDateKey is greater than Now(),  the contract is actually "Active", not "Expired".

 

View solution in original post

7 Replies
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

 

You can try Date#() function:

 

=if(date(EndDateFullDate)>date#('01-05-2023', 'DD-MM-YYYY') and date(EndDateFullDate)<date#('31-12-2023', 'DD-MM-YYYY'),'yes','no')

Help users find answers! Don't forget to mark a solution that worked for you!
TheresaB_4
Contributor III
Contributor III
Author

Thank you so much. It works!!

TheresaB_4
Contributor III
Contributor III
Author

Hi,

 

If I want to do this in the editor. I would like to mark the expired contracts. But this is not a date field.

I have a the following:

LOAD

StartdateKey,

EndDateKey,

If(EndDateKey > Now(),'Expired','Active') AS Contract_Status
FROM
[$(QVDLocation)$(vCountry)_QVDs/FactMeteringPointContractLine.QVD](qvd);

Thanks

Theresa

steeefan
Luminary
Luminary

What's the content and format of EndDateKey?

TheresaB_4
Contributor III
Contributor III
Author

It is an integer.

TheresaB_4_0-1704461685505.png

 

steeefan
Luminary
Luminary

Convert that int to a date, then compare:

 

If(Date#(EndDateKey, 'YYYYMMDD') > Now(), 'Expired', 'Active') AS Contract_Status

 

Also, if EndDateKey is greater than Now(),  the contract is actually "Active", not "Expired".

 

TheresaB_4
Contributor III
Contributor III
Author

Thank you so much it works