Question: I'm working with a fictional database where I have to calculate the tenure of employees. So, I want to do `'now' - hiredate = tenure`.

I've tried a few things but only `Null` is returned.

```sql
SELECT
    FirstName,
    LastName,
    HireDate,
    strftime('y%-m%-d%', HireDate) - strftime('y%-m%-d%','now') AS Tenure
FROM
    EMPLOYEES
ORDER BY
    Tenure

```

Answer: 
[`strftime`](https://sqlite.org/lang_datefunc.html) creates a string from a given (date)time value (***str***ing ***f***rom ***time***).

Instead, you should simply compare the julian days:

```sql
SELECT FirstName, LastName, HireDate, julianday('now') - julianday(HireDate) AS Tenure FROM EMPLOYEES ORDER BY Tenure

```
[SQLite's date functions](https://sqlite.org/lang_datefunc.html) like `strftime()` work only with dates in the format `YYYY-MM-DD`.  

If the column `HireDate` is in this format you can the difference of `HireDate` to the current date in seconds like this:

```
SELECT FirstName, LastName, HireDate, 
       (strftime('%s', CURRENT_DATE) - strftime('%s', HireDate)) AS Tenure 
FROM EMPLOYEES 
ORDER BY Tenure

```

because `strftime('%s', some_date)` returns the number of seconds passed since `1970-01-01` till `some_date`.  

Or the same difference in days with `julianday()`:

```
SELECT FirstName, LastName, HireDate, 
       (julianday(CURRENT_DATE) - julianday(HireDate)) AS Tenure 
FROM EMPLOYEES 
ORDER BY Tenure 

```

because `julianday(some_date)` returns the number of days since noon in Greenwich on November 24, 4714 B.C. till `some_date`.