I am trying to replace “.” with a “-” in a value that is returned from a sqlite database
I perform a normal
for row in db:nrows(“SELECT * FROM checkmarks;”) do
and then I try to convert the date to a string and then do the replace (in case the date is in the format 29.05.2018) so that I later can send this value to the server in the correct MySQL date format:
The value in row.theServiceDate was stored as the value retrieved from a Date field in a MySQL database on our server.
local tempServiceDate = row.theServiceDate print("245 tempServiceDate: "..tempServiceDate) tempServiceDate = string.gsub(tempServiceDate,".","-") print("246 tempServiceDate: "..tempServiceDate)
The result I get looks like this:
"245 tempServiceDate: 08-05-2018" "246 tempServiceDate: ----------"
I then tried to convert it to a string first, but with the same result
local theServiceDate = tostring(row.theServiceDate) print("247 theServiceDate: "..theServiceDate) theServiceDate = string.gsub(theServiceDate,".","-") print("248 theServiceDate: "..theServiceDate)
The result I get looks like this:
"247 theServiceDate: 08-05-2018" "248 theServiceDate: ----------"
How can I do a proper replace, without having to retrieve the day, month, year values in separate variables?