Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to parse input string in BigQuery with parse_date

I have a column 'appointment_date' in string formate representing a date dd.mm.yyyy.

In BiqQuery I am using the following query to find all appointments dates lying in the future:

SELECT appointment_date
FROM `appointments` 
where parse_date('%d.%m.%Y', appointment_date) > current_date()

BiqQuery returns the following error message: Failed to parse input string ""

Please advice.

Thanks, Janine

like image 370
janinw Avatar asked Oct 28 '25 05:10

janinw


1 Answers

Use safe.parse() to avoid the error:

where safe.parse_date('%d.%m.%Y', appointment_date) > current_date()

This will return NULL for invalid formats rather than an error.

like image 160
Gordon Linoff Avatar answered Oct 31 '25 09:10

Gordon Linoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!