function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Meggan Landis 11Meggan Landis 11 

Formula to populate custom date/time field using static time and today's date

Does anyone know how to write a formula that will populate a date/time field with today's date and 12:00 PM? I can't just use TODAY() because I need to be able to filter specifically for the 12:00 PM time stamp. Thanks!
Hemant Patel 22Hemant Patel 22

DATETIMEVALUE(TEXT(TODAY())+" 06:30:00")

 

above formula can be used to generate what you require, 

 

" 06:30:00" --> This I have done to adjust my local time zone, as I am in IST it is +5:30 from GMT so whatever is your timezone you can calculate like

 

"12:00:00" - (your time zone offset), my offset was +5:30 so it was substracted if your offset is -5:30 then it will be added and the formula will become

 

DATETIMEVALUE(TEXT(TODAY())+" 17:30:00")

SubratSubrat (Salesforce Developers) 
Hello Meggan ,

You can use the DATETIMEVALUE() and DATE() functions in combination with the TEXT() function to achieve this. 
 
DATETIMEVALUE(TEXT(DATE(TODAY())) + ' 12:00:00 PM')


In this formula, TODAY() returns today's date, which is passed to the DATE() function to get just the date portion without the time. Then, the TEXT() function is used to convert the date to a string format that can be concatenated with the static time value of 12:00 PM. Finally, the DATETIMEVALUE() function is used to convert the concatenated string to a date/time value.

With this formula, the custom date/time field will be populated with today's date at 12:00 PM, which you can then filter on to get the desired results.

If you find this helpful , please mark this as Best Answer.
Thank you.