Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
0li5a3a
Creator III
Creator III

timestamps error

Hi there,

I have a filed in my DB which contain the Date with the stamp, If I put the colun in a chart or table I can see the timestamp but if I create a text box to display thre  date is display only -.

I need to calculate the number of hours between the time now() and my date from my DB and display red if is more then 12h or green if is < 12h.

I have tried

=if(Num(Hour(interval(now()-Date)))>'12:00:00','Red','Green') but this is not right.

Regards,

1 Solution

Accepted Solutions
sunny_talwar

How about this

=If((Now() - Date) > MakeTime(12), 'Red', 'Green')

View solution in original post

4 Replies
sunny_talwar

How about this

=If((Now() - Date) > MakeTime(12), 'Red', 'Green')

Chanty4u
MVP
MVP

expression working in text box

grn.PNG=if(Num(Hour(interval(now()-Date)))>'12:00:00','Red','Green')

sasiparupudi1
Master III
Master III

what is your timestamp format

Peter_Cammaert
Partner - Champion III
Partner - Champion III

A few preliminary remarks:

  • Are you sure Date contains a Datetime value that QlikView can understand? If the text string (that's what you get out of a DB most of the time) cannot be interpreted as a Datetime value, then Now()-Date will produce a NULL value and you will get a hyphen in your text box.
  • Are you sure that field Date at any moment contains just a single value? Fields can have multiple active values. If you then use that field in an expression, QlikView will implicitly apply an Only() call to the field and that call will return NULL if more than one value is active.

BTW the simplest expression is probably this (on condition that Date has but a single correct DateTime value):

=IF (LocalTime() - Date > 0.5, 'Red', 'Green')