stephencelis / SQLite.swift

A type-safe, Swift-language layer over SQLite3.
MIT License
9.67k stars 1.56k forks source link

Question: Filter by date. #962

Open Samback opened 4 years ago

Samback commented 4 years ago

Hi there, I just wanna filter all dates that older than 24 hours. I was trying to do it like this https://github.com/stephencelis/SQLite.swift/blob/master/Documentation/Index.md#date-time-values But it doesn't work for me :(

E.g:

let table = self.table
let boundDate = Date(timeInterval: -86400, since: Date())
let query = table.filter(self.date <= boundDate )
print(query.asSQL())

As a result I get zero items. My SQL query logs print next

SELECT * FROM "logs" WHERE ("date" <= '2019-10-15T18:54:18.109')

What I'm doing wrong?

nathanfallet commented 3 years ago

This might be a problem with date formatting (I guess, else I don't know where is the problem) Linked to #985