Skip to main content
November 20, 2023
Solved

Date and time comparison

  • November 20, 2023
  • 3 replies
  • 0 views

I am having date and time of submitted form in Date time format.
I want to compare the date and time if it exceeds 1 hr from submission I want to show a proceed button.

How I can give a condition where it is comparing submitted form have completed 1hr 

Best answer by sriramk5349

Hi [mention:1078504a9e4c4d09a48c2f14d0358875:e9ed411860ed4f2ba0265705b8793d05] ,

Please use below code. Here local!proceedButton is a boolean which can be used for showWhen or disable parameter of buttonWidget.

a!localVariables(
  local!submittedTime:datetime(2023,11,20,03,35,00),
  local!proceedButton:a!addDateTime(local!submittedTime,0,0,0,1,0,0)>now(),
  local!proceedButton
)

3 replies

November 20, 2023

Assume the variable "submissionDatTime". that holds the submitted date and time. then, after you want to show the proceed button, if more than 1 hour has passed since submission.
Use this expression:
if(

currentDateTime() - submissionDateTime > 1 hour,
true,

false,

)
current DateTime get your current date and time

submissionDateTime shows your form's submitted date and time.

currentDateTime() - submissionDateTime , calculate the difference between these times.

1 hour is a threshold you want to check against. if your time difference is greater than 1 hour, the condition is true. then it will eveluate to true, and you can use this condition to visibility of proceed button.

sriramk5349
November 20, 2023

Hi [mention:1078504a9e4c4d09a48c2f14d0358875:e9ed411860ed4f2ba0265705b8793d05] ,

Please use below code. Here local!proceedButton is a boolean which can be used for showWhen or disable parameter of buttonWidget.

a!localVariables(
  local!submittedTime:datetime(2023,11,20,03,35,00),
  local!proceedButton:a!addDateTime(local!submittedTime,0,0,0,1,0,0)>now(),
  local!proceedButton
)

November 20, 2023

a!localVariables(
  /* Date from DB */
  local!dateTime: todatetime("20/11/2023 09:45"),
  /* Extract time */
  local!time: totime(local!dateTime),
  /* Get hour by having difference */
  local!differnce: tointeger(
    index(
      split(totime(now() - local!time), ":"),
      1,
      null()
    )
  ),
  /* Get the required value based on calculation */
  if(local!differnce >= 1, true, false)
)

Hi  [mention:1078504a9e4c4d09a48c2f14d0358875:e9ed411860ed4f2ba0265705b8793d05] , you can create a rule which calculates the difference and based on that you can either show or hide buttons.