Forum Discussion
Time Comparisons with NOW()
Hello,
In a measure, I am trying to compare the time from NOW()to a static value using TIME(), but it is only working on the < condition. The function NOW() is returning 7/28/2020 11:18AM
What I tried:
NOW() < Time(3,30,0) -> returns False
NOW() > Time(3,30,0) -> returns blank()
Am I doing something wrong? I have tried wrapping both the NOW() and TIME() functions in TIMEVALUE(), but that seems redundant. I'm kicking myself over this one as it seems so trivial.
Any help would be greatly appreciated
9 Replies
- amitchandakSuper User
Anonymous . because now is date and time. time is only time
Try like
NOW() < today()+ Time(3,30,0)
NOW() >today()+ Time(3,30,0)
- AnonymousNot applicable
amitchandak This works with the first condition, but it is still returning Blank() when I try:
NOW() > Today() + Time(3,30,0)
- Tahreem24Super User
Anonymous ,
Try like a below:
Column1 = IF(NOW()>TODAY()+Time(3,30,0),"Yes","No")Column2 = IF(NOW()<TODAY()+Time(3,30,0),"Yes","No")
- MFelixSuper User
Hi Anonymous ,
I have use the same formulas and getting true and false as expected.
What version are you using, and is this a part of a bigger syntax?
- AnonymousNot applicable
MFelix I am using Version 2.83 (July release) and It is part of a bigger syntax, but I'm testing only the time comparison component. Here is the full code that I am using right now:
Measure =VAR cur_time = UTCNOW() - TIME(4, 0, 0) //Converts to ESTVAR Hold = OR(If(cur_time<TIME(3,30,0) && Dates[Days from Today]=-1, true, false),If(cur_time>=TIME(3,30,0) && Dates[Days from Today]=0, true, false)) //We only show the current day after 330preturn If(cur_time > Today() + TIME(3,30,0), true, false)- MFelixSuper User
Is the days from today a column or a measure?