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)
Thanks
DateTime Fields
Pay attention that MySqlDataAdapter editor uses DataGrid component.
Use the following sample code to ensure that MySQLDirect .NET returns DateTime value in this case
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())
Console.WriteLine(reader[0].GetType());
}