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

Time:08-24

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

CodePudding user response:

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
   )
  • Related