Problem saving empty date fields to Retool DB

So I have a simple form that saves data to a Retool DB. The form contains two "Date Time" and "Date" fields, nothening to fancy. Only one "Date Time" field is required, the other fields are optional. The fields don't have a default value, and use the default formatting. The two "Date Time" fields have the "manage time zone" toggle selected and both use "Local time" for display and value. Now when all the date fields are populated I get no error. When one or more date fields are left blank/empty I get the following errors depending on the type of date field.

invalid input syntax for type date

invalid input syntax for type timestamp with time zone

I'm scratching my head on this one but I think it has something to do with the Retool DB. Maybe the date fields in the DB are configured wrong. IDK

Welcome to the forum @Jeff76

I have to dodge this particular pothole quite often.

You have to send a null back to the database if the date or time components are not populated. This is the easiest way:

I did not give the job_date the same treatment as start_time and end_time as it is a required field.

3 Likes

Looks like that solved my issue. Thanks

1 Like