I’m trying to calculate TimeSpans between dates. I have no problem with this if the date is formatted using the native sqlite3 format ‘YYYY-dd-mm’
How would I do this if the date is formatted differently, such as ‘dd-mm-YYYY’
I’ve tried the following with no success.
–Select days between two days; this works if the datetime string is formated YYYY-dd-mm
SELECT julianday(date1) - julianday(date2) AS Span from myTable;
–I tried this for dates in the format of dd-mm-YYYY but it doens’t seem to work
–It seems to be that a date format cannot be specified.
SELECT julianday(strftime('%d-%m-%Y', date1)) - julianday(strftime('%d-%m-%Y', date2)) AS Span from myTable;
Since you’re using System.Data.SQLite I would recommend using a custom function. This will be easier to use and be consistent with MS SQL Server, making it clearer for other .NET developers to understand and maintain.