Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get Local datetime on Function field

syamano
Tera Contributor

I created a function field that extracts only the date and time from the opened_at column as follows.

glidefunction:substring(opened_at, '12', '2')

 

However, the opened_at column is in UTC, I cannot obtain the correct value in the local datetime.
Is there a solution?

5 REPLIES 5

@Bhuvan  

Thank you for your help.

 

I understand how to set the date in opened_at to local time in advance.
This may be one possible solution.
However, I would like to set the function field to local time for opened_at in records that were created in the past as well.

Ankur Bawiskar
Tera Patron
Tera Patron

@syamano 

that's correct, it will give UTC time as system always store value in UTC.

try to use getDisplayValue() and see if that works, I am not sure if that works or not

glidefunction:substring(opened_at.getDisplayValue(), '12', '2')

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

Thank you for your help.

I tried to use  getDisplayValue(), but it was shown in the image below:

syamano_0-1754285290742.png