I am having trouble calculating the difference in the number of days between two date columns in two separate tables.
I have tried date_diff, date_between, and julianday but the error says these functions do not exist. Below is the code. Kindly assist.

SELECT created_at, cast(julianday(substr(u.createdat, 1, 10)) - julianday(substr(tb.date, 1, 10)) as ‘date difference’)
from table 1 u
join table 2 tb on u.phone = tb.phone
where u.created_at is not null

Welcome to the forum :smiley: What data source are you using? Postgres? MySQL? That will determine which functions are available.

Hi! I am using MySQL.

Then you can use the MySQL DATEDIFF function: https://www.w3schools.com/Sql/func_mysql_datediff.asp