Skip to main content
March 21, 2025
Solved

Default date and time

  • March 21, 2025
  • 2 replies
  • 0 views

Hi Team,

I have a requirement where the default date and time field should display the nearest rounded time. For example:

  • If the current time is 3:54 PM, the default time should be set to 4:00 PM.
  • If the current time is 4:01 PM, the default time should be set to 4:30 PM.

Is there any simple way to acheive this

    Best answer by mathieud0001

    datetime(
        year(now()),
        month(now()),
        day(now()),
        if(
          minute(now()) <= 30,
          hour(now()),
          hour(now()) + 1
        ),
        if(minute(now()) <= 30, 30, 0)
      )

    2 replies

    March 21, 2025

    Hi [mention:deff62be03f6435fa6e0034326944867:e9ed411860ed4f2ba0265705b8793d05] ,

    you could try something like this

    a!localVariables(
      local!min: minute(now()),
      a!addDateTime(
        startDateTime: now(),
        years: 0,
        months: 0,
        days: 0,
        hours: 0,
        minutes: if(
          and(local!min => 30, local!min < 60),
          60 - local!min,
          30 - local!min
        )
      )
    )

    mathieud0001
    March 21, 2025

    datetime(
        year(now()),
        month(now()),
        day(now()),
        if(
          minute(now()) <= 30,
          hour(now()),
          hour(now()) + 1
        ),
        if(minute(now()) <= 30, 30, 0)
      )