DateTime Fields

DateTime Fields

Postby mwerner » Wed 22 Jun 2005 16:42

I have a MySQL database that stores employee timecards information. I am trying to pull part of that information into VB so I can them manipulte the data and export it to a Crystal Report. I have two fields called timeIN and timeOut that hold the Unix time of the event. I can pull the Unix time into VB but I want to convert it before I pull it in. I am using the FROM_UNIX command as part of my SQL command but when I display the information in a datagrid on my windows form it only shows the date. However if I issue the same SQL command in the SQL Control Center it returns the date and time. For some reason VB truncates everything after the date. Below is my SQL Command

SELECT users.nameFirst, users.nameLast, users.HID, FROM_UNIXTIME(eventLog.timeIn) As timeIn,From_UNIXTIME(eventLog.timeOut) AS timeOut, users.payRate, users.typeID FROM users Left Join eventLog ON eventLog.usersID=users.usersID WHERE eventLog.timeIn BETWEEN 1118620859 And 1119009599

Note I have hard coded some information for testing that I will set programatically when I am done with the application (shown in italics)


Postby Serious » Thu 23 Jun 2005 08:44

MySQLDirect .NET populates a DateTime value.
It is behavior of DataGrid component that only date is visible.

Postby Guest » Thu 23 Jun 2005 13:02

Serious wrote:MySQLDirect .NET populates a DateTime value.
It is behavior of DataGrid component that only date is visible.

This is not a true statement. I get the same results when I view the results in the mySQLDataAdapter preview window.

Postby Serious » Thu 23 Jun 2005 13:20

Pay attention that MySqlDataAdapter editor uses DataGrid component.
Use the following sample code to ensure that MySQLDirect .NET returns DateTime value in this case
Code: Select all
MySqlCommand command = new MySqlCommand("select FROM_UNIXTIME(f_utime) from utime", connection);
using (MySqlDataReader reader = command.ExecuteReader()) {
if (reader.Read())

Return to dotConnect for MySQL