Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

asmithbi
Contributor II

Timestamp Comparison to Standard Timestamp

Hello,

I need to add a background color based on whether a timestamp is before or after 12:00PM.  If the timestamp is before 12:00PM, the background color will be Red().  If the timestamp is after 12:00PM the color will be Green().  The issue is how do I evaluate the timestamp to compare to my standard of 12:00PM?  Below is what I came up with, but it's not working.  I know the issue is in the "Timestamp('12:00','hh:mm')," portion of the expression.  Thank you in advance for any assistance on this issue. 

If(Timestamp(Date ,'hh:mm')<=Timestamp('12:00','hh:mm'),Red(), Green())

Tags (1)
1 Solution

Accepted Solutions
MVP
MVP

Re: Timestamp Comparison to Standard Timestamp

maybe with hour

if(hour(date) <= 12, ..., ...)

5 Replies

Re: Timestamp Comparison to Standard Timestamp

If Date is a datetime field then trying frac 'ing it :

     If(Timestamp(frac(Date ,'hh:mm'))<=Timestamp('12:00','hh:mm'),Red(), Green())

MVP
MVP

Re: Timestamp Comparison to Standard Timestamp

maybe with hour

if(hour(date) <= 12, ..., ...)

MVP
MVP

Re: Timestamp Comparison to Standard Timestamp

You need to convert the TimeStamp in Time Format before comparing...

=If(Time(Frac(TImeStamp(NOW())),'hh:mm')>=Time#('12:00','hh:mm'),GREEN(),RED())

Use your TimeStamp Field instead of NOW()

asmithbi
Contributor II

Re: Timestamp Comparison to Standard Timestamp

That did the trick.  Thank you Massimo!!

asmithbi
Contributor II

Re: Timestamp Comparison to Standard Timestamp

Thank you Manish.  I can use this on other apps.