Question
· Oct 12, 2020

Convert numeric expression(202010011000) to datetime format (8/6/2018 9:10 PM)

Hi Team,

I want to convert numeric expression (202010011000) to datetime format(8/6/2018 9:10 PM)

Thanks,

Ankur Shah 

Discussion (5)0
Log in or sign up to continue

it's easy, without AM/PM

write $tr("abcd-ef-gh ij:kl:00","abcdefghijkl",202010011000),! // ODBC-Format
write $tr("gh.ef.abcd ij:kl:00","abcdefghijkl",202010011000),! // German-Format
write $tr("ef/gh/abcd ij:kl:00","abcdefghijkl",202010011000),! // US-Format

but if you need AM/PM, then the shortest way is using $zd()/$zth() functions

set datetime=202010011000
set tmp=$tr("abcdefgh ij:kl:00","abcdefghijkl",datetime) // or using $e(...)
set tmp=$e(datetime,1,8)_" "_$e(datetime,9,10)_":"_$e(datetime,11,12)_":00" write $zdt($zdth(tmp,3),1,3)