Supabase: Check if Date field is empty (null)

I got a table with a delivery date field. I want to insert a specific date into this field if it’s empty. But whatever SELECT condition I use, WeWeb either reports an error (invalid input syntax for type timestamp) or does not return any record.

I tried value = “” or null as well as less than
image

How can I check whether a Date field is empty (null saved in database table)?

@BertrandG just leave the Date alone :slight_smile:

image

Thanks! However, I get another error now:
"Error: date/time field value out of range: “0”
Any other idea?

I do now know what you would like to accomplish.
You should try if(item.data.t_delivery_date, item.data.t_delivery_date, date()) if you want to put todays date or any other valid date variable :slight_smile:

You misunderstood me: I first want to check whether the delivery date field is empty. The result of this check is used in a True/False split action. If it’s empty a date is saved in the field. My issue is that I can’t find a condition for empty.

I got your case now!

if(context.item.data?.[‘date’],true,false)

image

Sorry, but it still doesn’t work. But I might have found the reason:

I’m clicking on a Save date button on Project level. This saves the date in the Projects table. But the same workflow should then also enter the date in the Tasks table.
The context uses the data from the Project level; this is probably why there’s an error (invalid input syntax for type timestamp: “false”).

Additional issue: A project can have more than 1 task. I’m determining the number of tasks in a project, then I’m using a loop to check for each tasks if it already has a delivery date. The problem is that I don’t know how to skip tasks with delivery_date. Should I use an array like this:

task_id 1, delivery_date 1 (or null)
task_id 2, delivery_date 2 (or null)
etc.
Any idea how I can do this easily?

I found a solution using an array. It contains the task_id and the delivery_date. A loop checks if the delivery date is empty, inserts the date in the database, and removes the first item from the array until it’s empty. It took me some time to figure this out but I learned a lot!