Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

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

  • 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)

    • Anonymous's avatar
      Anonymous
      Not applicable

      amitchandak This works with the first condition, but it is still returning Blank() when I try:

      NOW() > Today() + Time(3,30,0)

      • Tahreem24's avatar
        Tahreem24
        Super 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")
         
         
  • 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?

    • Anonymous's avatar
      Anonymous
      Not 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 EST
       
      VAR 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 330p
       
      return If(cur_time > Today() + TIME(3,30,0), true, false)
      • MFelix's avatar
        MFelix
        Super User

        Is the days from today a column or a measure?