Forum Discussion

HunnyVinod_Kuma's avatar
Qrew Member
6 months ago

Comparing time value with current time value using Now() function

I want to compare the time value currently we have in our data with the current time value and I'm using Now() function for this but due to seconds difference it is not able to compare. For example: if we have the date time value as 12/21/23 3:30PM and I want to check if current time is equal to 12/21/23 3:30PM (Now()= 12/21/23 3:30PM) then return true else false but due to seconds value it is giving incorrect result/false.

Any suggestions to solve this?



Hunny Vinod Kumar

1 Reply

  • On option is to break out the components and compare the date, current hour and current minutes as part of the output. So something like: 

    var datetime fieldDT = [Your Field with Date/Time];

    var timeofday fieldTOD = ToTimeOfDay($fieldDT);

    var timeofday nowTOD = ToTimeOfDay(Now());

    ( ToDate($fieldDT) = ToDate(Now())) and

    ( Hour($fieldTOD) = Hour($nowTOD) ) and

    ( Minute($fieldTOD) = Minute($nowTOD) )

    Chayce Duncan