### Select Order for DateTime as Text

SQLite Select with Order Desc for a DateTime field declared as TEXT.
Example setting the dateformat, store in SQlite Database and Select with ORDER
Define Field
Field: Changed, Type TEXT
Set Datetimeformat
' Set datetime format - do not add the HH:MM, only the date format
DateTime.DateFormat = "YYYY-MM-dd"
Insert or Update Field
' Insert or Update the content of field changed
' Build the map holding the fields
Dim l As List
l.Initialize
Dim m As Map
m.Initialize
' fieldchanged is declared in the index.html file, like
' Changed:
'
m.Put("Changed", fieldchanged.GetVal.Value)
' or set using datetime
' Update the changed date
m.Put("Changed", DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now))
' Add other fields
l.Add(m)
' ADD
DBUtils.InsertMaps(Main.gSQL, Main.TblItemssName, l)
' UPDATE
m.Put("ID", id)
Dim w As Map
w.Initialize
w.Put("ID", id)
DBUtils.UpdateRecord2(Main.gSQL, Main.TblItemsName, m, w)
Select with Order
Dim cur As ResultSet
cur = Main.gSQL.ExecQuery("SELECT * FROM " & Main.TblScribblesName & " ORDER BY datetime(Changed) DESC")

Changed: , Category: SQLite, File: T6C254M1831.htm, ID: 1831