Home > OS >  Date formatting from string to date
Date formatting from string to date

Time:11-30

I am having date formatting with an uplaoded csv where date is a string with the following formate '10/30/2021 8:41 PM'; i am trying to change it into 'mm/dd/yyyy' in google big query, but keep getting an error saying Invalid Date or Invalid datetime. I have tried parsing it, using substrings, and even dropping the AM/PM but no use. Please let me know if you have any ideas as i did not find any solution online thus far

CodePudding user response:

from string to date

Consider below example

select date(parse_datetime('%m/%d/%Y %I:%M %p', '10/30/2021 8:41 PM'))          

with output

enter image description here

  • Related