Reputation: 898
I'm trying to get DAYID as string in format YYYYMMDD, however its not working correctly.
I have a timestamp field, I take first 10 characters and convert it into date (working correctly)
toDate(substring(EventTimestamp,1,10))
-- 2021-03-24
However when I try to convert to string using below expression, I;m getting wrong answer. I;m getting the Day as 83.
toString(toDate(substring(EventTimestamp,1,10)),'YYYYMMDD')
--20210383
Upvotes: 1
Views: 380
Reputation: 14379
Date format characters are case-sensitive as per this answer here, so use yyyyMMdd
instead.
An example using formatDateTime
:
@formatDateTime(utcnow(), 'yyyyMMdd')
Upvotes: 1