Android Question SOLVED Some issue with DBUTILS

tigrot

Well-Known Member
Licensed User
Longtime User
Hi Everybody
I'm trying to set date('now') using dbutils in a sqllite db.
I've some problem the date('now') seems to be resolved as string instead of a date function.
Maybe the issue is the SqlLite itself.
If I look to the value in datacreazione field i find the litteral Date('now') instead of yyyy-mm-dd...

B4X:
        Dim ListOfMaps As List
        ListOfMaps.Initialize
        Dim m As Map
        m.Initialize
        m.Put("Id", Main.codpratica)
        m.Put("cognome", edittext1.text)
        m.Put("nome", edittext2.Text)
        m.Put("tipo",edittext3.text)
        m.Put("tag",edittext4.Text)
        m.Put("datacreazione", "Date('now')")
        m.Put("livello",Main.livello)
        m.Put("utente",Main.userx)
        ListOfMaps.Add(m)
        DBUtils.InsertMaps(Main.SQL, "pratiche", ListOfMaps)

Does anybody have the same problem. I could extract the value for date but this is a too simple workaround!!!

Grazie a tutti
Mauro
 

keirS

Well-Known Member
Licensed User
Longtime User
I think it's probably a problem with DBUtils and not SQLite. It's perfectly possible to do an INSERT command with a date function in SQLite. Does your SQLite column have it's affinity set as DateTime or Date?
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
I think it's probably a problem with DBUtils and not SQLite. It's perfectly possible to do an INSERT command with a date function in SQLite. Does your SQLite column have it's affinity set as DateTime or Date?
I agree, most likely the issue is with DBUtils, i've used Date('now') before but without the dbutils and it works fine.

Cheers,
Walter
 
Upvote 0

tigrot

Well-Known Member
Licensed User
Longtime User
I have traced the DBUtils and seems to do the job. The Date('now') function is correctly inserted in INSERT statement. So the issue must be elsewhere... This is not a problem, since I can build the SQL INSERT on my own or pass the date as a value. This is the first time I use SQL Lite, so it's more an exercize for me than a real need. In MsSQL and MySql I use the date function on almost every DB to mark the creation date of each row, for future needs.
Thank you everybody. You are a high valued group!

Mauro
 
Upvote 0
Top