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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
salleninsd
Creator
Creator

Create EndMonth Flag in Script

Hello,

I am trying to flag when a date is an End of Month date with an if statement.  It appears the syntax is correct, but my results are returning an 'N' on the last day of the month.  Here is the script:

if(Date(MonthEnd([Census_Daily.CensusDate],'YYYY-MM-DD')=[Census_Daily.CensusDate],'YYYY-MM-DD'),'Y','N') as vIsCensusMthEnd,

Any suggestions are most appreciated.  Thank you!

Census EOM Flag.PNG

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

You don't need to do all the date fomatting stuff as long as all you need is a true or false to check against.

This should work for you:

If(Floor(MonthEnd([Census_Daily.CensusDate]))=Floor([Census_Daily.CensusDate]),'Y','N')


Be sure to use the Floor() function to remove any time part of the date. This is crucial since the MonthEnd() function doesn't only give you the last day of the month but also the very last minute and second before midnight on that date.

View solution in original post

5 Replies
petter
Partner - Champion III
Partner - Champion III

You don't need to do all the date fomatting stuff as long as all you need is a true or false to check against.

This should work for you:

If(Floor(MonthEnd([Census_Daily.CensusDate]))=Floor([Census_Daily.CensusDate]),'Y','N')


Be sure to use the Floor() function to remove any time part of the date. This is crucial since the MonthEnd() function doesn't only give you the last day of the month but also the very last minute and second before midnight on that date.

salleninsd
Creator
Creator
Author

Hi Petter,

Thank you so much for the quick response!  I just tried, and am still getting an N for the flag:

Month Flag Pic.PNG

salleninsd
Creator
Creator
Author

Just saw the rest of your message with the Floor(), and will try that...

salleninsd
Creator
Creator
Author

Wow!  Petter, you are my HERO!

Thank you so much for your help, it works!  I forgot about the timestamp possibility, and I've never used the Floor() function.  Learn something new every day!

Have a terrific evening!

Month Flag Pic.PNG

petter
Partner - Champion III
Partner - Champion III

You're welcome - happy to help.