0

I have stored date in a column of android sqlite database in YYYY/MM/DD format . Now I want to use julianday function in sql query to select special rows of database however julianday uses date in YYYY-MM-DD format . How can I convert date format inline with sql query?

Please rewrite this sample query which "startdate" and "enddate" are stored in YYYY/MM/DD format not YYYY-MM-DD:

select * from events where julianday(enddate)-julianday(startdate)>1200
Ali Sheikhpour
  • 10,475
  • 5
  • 41
  • 82

1 Answers1

1

SQL query accepts inline replace:

select * from events where julianday(replace(enddate,'/','-'))-julianday(replace(startdate,'/','-'))>1200

for more complex conversion use prepared SQL convert() function

Ali Sheikhpour
  • 10,475
  • 5
  • 41
  • 82