Skip to main content

Formula with today() and a set time

  • February 11, 2022
  • 3 replies
  • 65 views

Forum|alt.badge.img+5

Hey there…look for assistance with formula that uses the TODAY() function with a set time. I.e. I want the field to have the current date but with a set time so that it would show for example the current date that updates each day but always has 12:00 PM.

Thanks in advance for help

3 replies

ScottWorld
Forum|alt.badge.img+35
  • Genius
  • February 11, 2022

Someone might have a simpler & easier formula for this, but I just quickly whipped this together and it seems to work. You’ll want to choose your own timezone from the list of supported time zones.

DATETIME_PARSE(
DATETIME_FORMAT(SET_TIMEZONE(TODAY(),'America/Los_Angeles'),'MM-DD-YYYY') 
& " 12:00 PM",
'MM-DD-YYYY h:m A')

Justin_Barrett
Forum|alt.badge.img+21

Someone might have a simpler & easier formula for this, but I just quickly whipped this together and it seems to work. You’ll want to choose your own timezone from the list of supported time zones.

DATETIME_PARSE(
DATETIME_FORMAT(SET_TIMEZONE(TODAY(),'America/Los_Angeles'),'MM-DD-YYYY') 
& " 12:00 PM",
'MM-DD-YYYY h:m A')

That works quite well. The only thing that I can add is that with a simple format like that, you can actually leave out the formatting string in the DATETIME_PARSE() function and it still parses correctly:

DATETIME_PARSE(
DATETIME_FORMAT(SET_TIMEZONE(TODAY(),'America/Los_Angeles'),'MM-DD-YYYY') 
& " 12:00 PM")

I find that specific formatting strings are really only needed when the source string format is non-standard; e.g. “Jan252022”.


ScottWorld
Forum|alt.badge.img+35
  • Genius
  • February 11, 2022

That works quite well. The only thing that I can add is that with a simple format like that, you can actually leave out the formatting string in the DATETIME_PARSE() function and it still parses correctly:

DATETIME_PARSE(
DATETIME_FORMAT(SET_TIMEZONE(TODAY(),'America/Los_Angeles'),'MM-DD-YYYY') 
& " 12:00 PM")

I find that specific formatting strings are really only needed when the source string format is non-standard; e.g. “Jan252022”.


Thanks, @Justin_Barrett! That’s great to know, and it’s a great simplification! :slightly_smiling_face: