Creating if statement to get the time in-between two dates, but if the need by date is NULL then I want to use The create date

  • 22 September 2022
  • 2 replies
  • 32 views

I have this so far. I want to find the number of days between the need by date and the receipt date, but if the need by date is NULL then I want to use the create date. What am I getting wrong? 

 

if(${orders.need_by_date}=null,diff_days(${orders.created_date},now()),diff_days(${orders.need_by_date},${receipts.receipt_created_date}))


2 replies

In SQL you can’t equate to null instead you should write as ${orders.need_by_date} is null

Userlevel 7
Badge +1

And in the table calculation you need to use is_null() function

Reply