Hi all,
today I observed a surprising event.
A field in a MySQL DB is set as DATE datatype. If at the console I enter something like
INSERT INTO mytable (ddn) VALUES('1960-01-01')
using Toad I see that field as 01/01/1960 12:00:00 AM. So everything looks ok.
Using B4J, I make use of an ADP (AnotherDatePicker) to read its Date property (a long datatype), store it in a Map, trasmit the map over the Internet, read again as a Map, set DateFormat to "yyyy-MM-dd" to comply with MySQL and finally execute an INSERT into my table.
When I read it back (or look at it through Toad) I see it as '12/31/1959 12:00:00 AM'.
What could it be?
Here's my code before inserting into the table
Note: the server (hosting both MySQL and a B4J "server" component) is located in a different Timezone then the PC running the client (which uses ADP to collect the date to be recorded).
udg
today I observed a surprising event.
A field in a MySQL DB is set as DATE datatype. If at the console I enter something like
INSERT INTO mytable (ddn) VALUES('1960-01-01')
using Toad I see that field as 01/01/1960 12:00:00 AM. So everything looks ok.
Using B4J, I make use of an ADP (AnotherDatePicker) to read its Date property (a long datatype), store it in a Map, trasmit the map over the Internet, read again as a Map, set DateFormat to "yyyy-MM-dd" to comply with MySQL and finally execute an INSERT into my table.
When I read it back (or look at it through Toad) I see it as '12/31/1959 12:00:00 AM'.
What could it be?
Here's my code before inserting into the table
B4X:
'NUser is the map received from the client using ADP
Dim temp As String = DateTime.DateFormat 'save current format for later restoring
DateTime.DateFormat = "yyyy-MM-dd"
Dim ddn As String = DateTime.Date(NUser.Get("ddn"))
Dim sql1 As SQL = pool.GetConnection
...
sql1.ExecNonQuery2($"INSERT INTO mytable
(id,name,ddn,addr1)
VALUES(?,?,?,?)"$, _
Array As Object(Null, NUser.Get("name"), ddn, NUser.Get("addr1")))
...
Note: the server (hosting both MySQL and a B4J "server" component) is located in a different Timezone then the PC running the client (which uses ADP to collect the date to be recorded).
udg
Last edited: