Skip to content
Advertisement

Big Query – Convert INT to Date

Can not find any solution to this:

Need to convert date(int) in the format – 20190101 to DATE in the format “2019-01-01”

I have tried:

  • Cast(cast(20190101 AS STRING) AS date)
  • FORMAT_DATE(“%F”,CAST(20190101 AS STRING))
  • And so on…no success

Advertisement

Answer

You are looking for PARSE_DATE():

select PARSE_DATE('%Y%m%d', CAST(20190101 AS STRING))
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement