简体   繁体   中英

Convert string to date in google big query

I have a string column which has date value in the below format

6/1/2020 12:00:00 AM

I want only the date part and convert the column to date so when i use date_trunc and parse date like below it is giving error

select CAST(DATE_TRUNC(PARSE_DATE('%m/%d/%Y', datecolumn), AS DATE)) from table name

PLease let me know what is the best way to achieve this

Use below

select date(parse_datetime('%m/%d/%Y %I:%M:%S %p', datecolumn))
from your_table

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