mysql curious behavour of datetime field

Post

Posted
Rating:
#1 (In Topic #295)
Regular
bill-lancaster is in the usergroup ‘Regular’
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

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
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
bill-lancaster is in the usergroup ‘Regular’
 It must be an issue with UTC vs local time but I'm not sure what to do about it at the moment
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Regular
Cedron is in the usergroup ‘Regular’
Hi Bill,

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

[Gambas-user] A little bit of Date Testing

[Gambas-user] Using dates in Gambas

Hopefully, that'll help you out a bit.

Ced

.... and carry a big stick!
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
bill-lancaster is in the usergroup ‘Regular’
Thank you Cedron
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Administrator
sholzy is in the usergroup ‘unknown’
Not just mySQL with a GridView, but also SQLite with GridView.

sholzy
Gambas One Site Director

To report bugs in the Gambas IDE:
Official Gambas Bug Tracker
Online now: No Back to the top
1 guest and 0 members have just viewed this.