Page 1 of 1

mysql curious behavour of datetime field

Posted: Friday 26th July 2019 9:55am
by bill-lancaster
I have a datetime field in a mysql database. I recently added a record with the value 07/25/2019 23:00:00 (I think)
When displayed in a gridview table 07/25/2019 23:00:00 is shown but "print hResult!DateTime" shows "26/07/2019 00:00:00"
I have made a simple programme that creates a new record " hResultNew!TestDateTime = Date(2019, 7, 29, 23, 30, 00)" but the display in gridview has the wrong time.
What's going on here!
I hope I'm not doing something stupid but any ideas are welcome

Code: Select all

Private hConn As New Connection
Private hResult As Result

Public Sub Form_Open()
Dim i As Integer
   ' hConn = MysqlLibrary.DbConnect("test")
   With hconn
      .Type = "mysql"
      .Port = "3306"
      .Host = "localhost"
      .User = "root"
      .Password = "*******"
      .Name = "test"
      .Open()
   End With
   hResult = hConn.Find("general")
   gdvTest.Columns.Count = 2
   gdvTest.Rows.Count = hResult.Count
   For Each hResult
      gdvTest[i, 0].Text = hResult!id
      gdvTest[i, 1].Text = hResult!TestDateTime
      Print hResult!TestDateTime      
      Inc i
   Next
End

Public Sub Button1_Click()
Dim hResultNew As Result
   hResultNew = hConn.Create("general")
   hResultNew!TestDateTime = Date(2019, 7, 29, 23, 30, 00)
   hResultNew.Update
End
Gambas 3.13.0

Re: mysql curious behavour of datetime field

Posted: Friday 26th July 2019 10:11am
by bill-lancaster
It must be an issue with UTC vs local time but I'm not sure what to do about it at the moment

Re: mysql curious behavour of datetime field

Posted: Friday 26th July 2019 5:44pm
by Cedron
Hi Bill,

That's exactly what it is. It was recently discussed on the mailing list.

https://lists.gambas-basic.org/pipermai ... 67372.html

https://lists.gambas-basic.org/pipermai ... 67220.html

Hopefully, that'll help you out a bit.

Ced

Re: mysql curious behavour of datetime field

Posted: Saturday 27th July 2019 6:58am
by bill-lancaster
Thank you Cedron

Re: mysql curious behavour of datetime field

Posted: Tuesday 30th July 2019 1:26am
by Got2BeFree
Not just mySQL with a GridView, but also SQLite with GridView.