SQLite Data Base Currency: I do it

We discussed recently about how to store / restore data from a SQLite data base, especially Currency.
Below is a project that just do that.

NB: The leftmost button is a debug for the dates stored in Tag of Column(1), as SQLDate.

Second note: the use of Locale for the Date AND for the Currency, of course !

What do the project do ?

  1. Click in Create
  2. Click in Import and choose the associated .txt file
  3. CLick in Read to load / display the data from the .sqlite file
  4. Click in Tag Debug to display the Tag associated with the Italian date (as you can read above, it’s a 8601 ISO date).
    As I wrote in the code, you can store a different value, both have to be Custom Sorted: to my great surprise, the code there works fine

Here’s the project ans the .txt Italian associated data:

Currency in SQLite.zip (11.0 KB)

Created with macOS Sequoia / Xojo 2024r3.1

1 Like

In PB_Read, why not simply do a:

LB.AddRow DateTime.FromString(row.Column("DataFattura").StringValue,ital).SQLDate

Maybe even (better be safe than sorry):

Try
  LB.AddRow DateTime.FromString(row.Column("DataFattura").StringValue,ital).SQLDate
Catch err As RuntimeException
  If err.Message <> "Date is not in an accepted format for parsing" Then Raise err
  LB.AddRow ""
End Try

Usually, when I use two lines of code instead of one it is because I had troubles and want to know who’s line is faultive. Looks like it is a case.

But well spotted.

Maybe even (better be safe than sorry):
as always, you are correct. But I knew the dates are OK.
Still, you are right. In everyday work I also saw (or sometimes heard on TV: “SEPTEMBER 31ST WILL SEE…” from a member of the Press… !) errors in dates (typos they say).

1 Like

Just for fun, I made mistakes in the date of the text file and your example program crashed. So I changed the following line:

aDateTime = aDateTime.FromString(aDateStr, Ital)

to

Try
  aDateTime = aDateTime.FromString(aDateStr, Ital)
Catch err As RuntimeException
  If err.Message <> "Date is not in an accepted format for parsing" Then Raise err
  aDateTime = DateTime.FromString("1970-01-01 00:00:00")
End Try

Since you want to help @Federico_Giannetti with your program, I think you could also point out possible challenges. Otherwise it will only lead to more questions. :blush:
Mainly to point out possible errors and possible solutions. Because, as you already mentioned, there are often misunderstandings when it comes to dates.

By the way, I think it’s great that you’re doing this work. Thank you very much for that @Emile_Schwarz.

1 Like