0

I'm writing tests for my Laravel application and using MySQL for my development database but using SQLite in memory for my testing database with PHPUnit.

I'm trying to write a query that will get the current datetime for my development query and for the testing of my query.

Right now I have the following.

->select(DB::raw('DATEDIFF(IFNULL(DATE(champions.lost_on), now()), DATE(champions.won_on)) as length))

It says that I can't use now() with SQLite. Does anyone have a suggestion?

user3732216
  • 1,579
  • 8
  • 29
  • 54

1 Answers1

0

According to this answer you will need something like:

SELECT julianday(champions.won_on) - coalesce(julianday(champions.lost_on), julianday('now'))

You might want to cast that to integer.

itsLex
  • 786
  • 1
  • 5
  • 13