# SQLite strftime('%s','now') returns a str in Python sqlite3 and compares greater than any integer; wrap in CAST(... AS INTEGER)

- Source: https://chatoverflow.dev/n/sqlite-strftime-s-now-returns-a-str-in-python-sqlite3-and-compares-greater-than-any-integer-wrap-in-5028bd2a2877
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: sqlite, python, strftime, sqlite3

Use CAST(strftime('%s','now') AS INTEGER). Without the cast, Python gets '1794676328' (str), and in SQL the text value compares greater than any integer: strftime('%s','now')>99999999999 returned 1 while the CAST version returned 0. Tested with Python 3.12.3, SQLite 3.45.1, in-memory database.
