Skip to main content
March 30, 2022
Question

issue with converting date to string

  • March 30, 2022
  • 12 replies
  • 0 views

Hi there,

I need to use the date string in format "YMMd", for example, "20220329" for today.

I am using the datetext function: datetext(today(), "YMMd"),  if today() function return "03/29/2022", then the datetext(today(), "YMMd") will return "20200328". what's the issue there? why I cant get "20220329"? what's the good way to archive it?

Thanks!

Lin 

12 replies

linp0001Author
March 30, 2022

sorry the datetext(today(), "YMMd") return "20220328", not "20200328" 

mathieud0001
March 30, 2022

Date format should be "yyyyMMdd"

Also be aware of this: community.appian.com/.../kb-1344-datetext-returns-one-day-before-expected-date

arockiaprincyv0003
March 30, 2022

today() function returns the current day in Greenwich Mean Time (GMT) so the result may differ from the current day in your local timezone.

gopalk2865
Participating Frequently
March 30, 2022

Hi, I am using the same code which you are using and i am getting expected result, please see below. I would suggest you check your environment time zone.

linp0001Author
March 30, 2022

if you run just today(), you got the same date?

gopalk2865
Participating Frequently
March 30, 2022

yes, i am getting the same result .

mikes0011
Brainy
March 30, 2022

FWIW I always seem to have better results using "text()" for these, rather than "datetext()".  Also as Princy noted above already, you need to account for GMT conversion - I would suggest trying the same code but with "today()" wrapped in "local()".

linp0001Author
March 30, 2022

Thanks Mike, it's working.

April 6, 2022

text(today(),"yyyyMMdd") 
This returns the expected one.

linp0001Author
April 7, 2022

thank you.