Skip to main content
Question

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

  • December 21, 2023
  • 0 replies
  • 143 views

Forum|alt.badge.img+3

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?

Regards,

Hunny



------------------------------
Hunny Vinod Kumar
------------------------------
This topic has been closed for replies.

Forum|alt.badge.img+9
  • Quickbase Alumni
  • December 21, 2023

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