0

I need to show current UTC timestamp in a format '2021/05/10T18:30:36Z'

SELECT UTC_TIMESTAMP() FROM XYZ

gives me 2021-05-10 18:30:36

how do i add the / instead of - and use T and Z

Lav
  • 1,283
  • 5
  • 21
  • 48

1 Answers1

2
select DATE_FORMAT(UTC_TIMESTAMP(),'%Y/%m/%dT%TZ')

2021/05/10T18:51:07Z

Note that T doesn't really mean anything. And Z means UTC ZERO timezone, which is always the case with the UTC_TIMESTAMP function. Thus I have somewhat "hardcoded" those letters at the right place , and they are not real variables accepted by DATE_FORMAT()

Thomas G
  • 9,886
  • 7
  • 28
  • 41