Hi there everybody,
I need some insight on sqlite limitation or different ways to save and sort data on sqlite.
I have to save in a sqlite table 2 dates (no time) and being able to sort the query results by date
I checked the sqlite and the clock instructions and I arrived to 2 options but implemented only one because I found quicker to code and store
ACTUAL SOLUTION: to be able to sort the query with the least of complications, I thought to save the dates as milliseconds as integer in SQLite. Millis are easy to convert to any format (one block). At this point, for reasons I don't understand the number saved are random and different from the insert/update query I use. I thought to be an INTEGER limitation but can't say for sure. Shall I use REAL insted? Is this the issue?
Option 2 not implemented because lengthy process to test a new option if #1 solution can work somehow: Use DATE function of SQLite. This option I'm almost sure works with ORDER option in SELECT query. The counterside is that I have to manipulate strings several time (showing date in the app, db saving format, convert db date format to app date format)
Any idea or suggestion to solve the issue with #1 or consider other possibilities?
Option 1, as you say, is easier and should be less problematic. In sqlite it should work as an integer. Show your blocks for creating the value to be stored in sqlite. Cannot understand why it would be "random".
@Taifun I checked the sqlite date options. a real changer would be if clock extension could add julian option which is more used out there. For sure a readable solution could be great but I only need it in dev stage. once in production level nobody is going to check the db. I have only to dip into date format output strftime() options and if still usable to order.
@TIMAI2 I'll pass some pics as soon as I can sit behind the pc. Starting point is to confirm clock millis produce number/integer and not a string. Also one check I'll try to do later on
It's realy no big deal to write a procedure, which converts the date from and to a format of your choice, for example to ISO-8601 date (e.g., 2024-10-24).
text will also work for order purpose I guess. Correct?
I didn't check but then when I retrieve the TXT I have to convert to number (millis) in AI2. At first quick look I didn't see a block for such conversion but can't say 100%. I did consider the txt option but didn't see the conversion block