Gambas Documentation
Application Repository
Code Snippets
Compilation & Installation from source code
Components
Controls pictures
Deprecated components
Developer Documentation
Development Environment Documentation
Documents
About The Best Formula In The World
Architecture details
Benchmarks
Books
By Reference Argument Passing
Compatibility between versions
Creating And Using Libraries
Database Datatype Mapping
Database Request Quoting
Date & time management
Dates and calendars
DBus and Gambas
Differences Between Shell And Exec
Differences From Visual Basic
Distributions & Operating Systems
Drag & Drop
DrawingArea Internal Behaviour
External functions datatype mapping
Frequently Asked Questions
Gambas Farm Server Protocol
Gambas Mailing List Netiquette
Gambas Markdown Syntax
Gambas Naming Conventions
Gambas Object Model
Gambas Scripting
Gambas Server Pages
Gambas Unit Testing
Gambas Wiki Markup Syntax
Getting Started With Gambas
Getting Started With The IDE
Hall Of Fame
Housekeeping, cleaning up
Image Management In Gambas
Including Help Comments in Source Code
Installation from binary packages
Interpreter limits
Introduction
Just In Time Compiler
Just In Time Compiler (old version)
License
Localisation and Internationalization
Mailing Lists, Forums & Social networks
Network Programming
ODBC Component Documentation
PCRE Pattern Syntax
Porting from Gambas 2 to Gambas 3
Previous News
Project Directory Structure
Release Notes
Reporting a problem, a bug or a crash
Rich Text Syntax
Screenshots
SQLite component documentation
Text highlighting definition file syntax
The Program has stopped unexpectedly by raising signal #11
Wayland and Gambas
WebPage Syntax
Web site home page
What Is Gambas?
Window & Form Management
Window Activation & Deactivation
Window Life Cycle
XML APIs
Error Messages
Gambas Playground
How To's
Language Index
Language Overviews
Last Changes
Learning topics
Lexicon
README
Search the wiki
To Do
Topics
Tutorials
Wiki License
Wiki Manual

SQLite component documentation

See also: How To Open a SQLite connection and use it

SQLite and dates

SQLite explicitly says that it does not support any date/datetime SQL datatype.

So you have to store date as strings or numbers, and handle the comparison between dates using special SQLite functions.

The Gambas SQlite driver decided to store date/time as strings.

For example, to make the BETWEEN comparison works, you must compare the date fields with values generated by the Gambas component, otherwise the comparison could only work by luck.

So, the request must be written that way:

Connection.Exec("SELECT * FROM clients WHERE fecha BETWEEN &1 AND &2", Date.FromUTC(Date(2025,05,14)), Date.FromUTC(Date(2025,05,15))

to get the following request:

SELECT * FROM clients WHERE fecha BETWEEN '2025-05-14T000000.000Z' AND '2025-05-15T000000.000Z'

Beware that the format changed between gb.db and gb.db2.

You will get another result with gb.db that does not store the date the same way.

Another solution is not using Gambas Sqlite date fields, but numeric fields, where you store date/time as a numeric timestamp. For example the number of second since the UNIX Epoch.

Then the field is not directly readable, but you are sure that comparisons will always work.