简体   繁体   中英

Cast CURRENT_TIMESTAMP to dd/mm/yyyy hh:mm string with BigQuery

I'm working with BigQuery and so the CONVERT() function isn't applicable here so I'm wondering how I'd be best to go about converting the current_timestamp into a string with the format "dd/mm/yyyy hh:mm"

I don't have to specifically use current_timestamp so if there is another method which doesn't make use of that, that would also be acceptable.

Before;

2022-08-23 15:13:27.234822 UTC

After;

23/08/2022 15:13

Thanks in advance

Try this - it'll format the current timestamp in the format you want then cast it to a string. See here for formatting options in Google SQL

CAST(
   FORMAT_TIMESTAMP('%d/%m/%Y %H:%M', CURRENT_TIMESTAMP())
   AS
   STRING
   )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM