mysql curious behavour of datetime field

Post Reply
bill-lancaster
Posts: 63
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

mysql curious behavour of datetime field

Post by bill-lancaster » Friday 26th July 2019 9:55am

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

bill-lancaster
Posts: 63
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: mysql curious behavour of datetime field

Post by bill-lancaster » Friday 26th July 2019 10:11am

It must be an issue with UTC vs local time but I'm not sure what to do about it at the moment

User avatar
Cedron
Posts: 99
Joined: Thursday 21st February 2019 5:02pm
Location: The Mitten State
Contact:

Re: mysql curious behavour of datetime field

Post by Cedron » Friday 26th July 2019 5:44pm

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
.... and carry a big stick!

bill-lancaster
Posts: 63
Joined: Tuesday 26th September 2017 3:17pm
Location: NW England

Re: mysql curious behavour of datetime field

Post by bill-lancaster » Saturday 27th July 2019 6:58am

Thank you Cedron

User avatar
Got2BeFree
Posts: 62
Joined: Saturday 26th November 2016 2:52am
Location: Lost

Re: mysql curious behavour of datetime field

Post by Got2BeFree » Tuesday 30th July 2019 1:26am

Not just mySQL with a GridView, but also SQLite with GridView.
sholzy

I'm wondering around lost in the past, not knowing where the present is.

Post Reply