Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
lbrs
Contributor II
Contributor II

difference between date and today date

Hi all,

thnaks for the support.

I am trying to calculate the difference between two date: 

the first is in the form [packet] = 30-08-2022 07:29:52

the second date is the today date.

i need the differene in day and put in an if statemant, if is more than 2 color in red else green.

I tried some solution but none worked fine.

qlick for the autofiller suggest some solution like [packet.autoCalendar.Year] but is not clear what are those used for.

 

if i have to search something on internet please tell me i will.

 

BR,

Luca

Labels (3)
5 Replies
Or
MVP
MVP

Simply subtract one date from the other, e.g. Today() - [packet]. Note that packet must be a date / timestamp field, not a text field which happens to be formatted like a date. If the latter is the case, use TimeStamp#() to convert it: https://help.qlik.com/en-US/qlikview/May2022/Subsystems/Client/Content/QV_QlikView/Scripting/Interpr...

 

lbrs
Contributor II
Contributor II
Author

thanks for the reply.

It shoult be in the date format from excell, i did try but it geve me no result, like:

if(today()-[packet] > 2, green(),red()) is always red.

is there something to understand the logic behind qlik and how it works?

maybe if i do understand how it use the data ill be able to understand, i dont know

PrashantSangle

try using interval()

if(Num(num#(interval(Today()-[packet],'D'),'#0))>2,green(),red())

Regards,

Prashant Sangle

 

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Or
MVP
MVP

"Should be" isn't a great thing to trust in. I'd recommend you go ahead and confirm that, and as suggested, use a conversion function if that is not the case.

If you get a result from today()-packet when used as a measure (e.g. in a KPI object or text object), and that result matches your expectations, then the issue is likely with the condition itself, but as I'm not sure what context you're using it in or how your data is structured, I can't really comment on that.

lbrs
Contributor II
Contributor II
Author

now is working . I had to agregate some data and add the floor function to your suggestion for both date in order to give out just the date. Thanks for the super support, it was helpfull.