• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

MySqlDataReader for TIME ?

When I try to read the MySql database field of type "TIME", using the MySql datareader, I get the following error:
      
   'MySql.Data.MySqlClient.MySqlDataReader' does not contain a definition for 'GetTime'      

I can read DateTime type, but not Time. So, how can I read the field of type TIME ?
0
pillmill
Asked:
pillmill
  • 2
1 Solution
 
Steve BinkCommented:
Looks like there isn't one.  There are readers for timespan, system.datetime, or mysqldatetime.

http://dev.mysql.com/doc/refman/5.1/en/connector-net-examples-mysqldatareader.html

The next seems to imply that you should be using the mysqldatetime object instead:

http://dev.mysql.com/doc/refman/5.1/en/connector-net-using-datetime.html

0
 
pillmillAuthor Commented:
OK. Is there a way then, to output the results so that the output is either:
a date(yyyy,mm,dd) OR a time (hr,min,sec) ? Thanks.
0
 
Steve BinkCommented:
You can use data conversion commands in the SQL.  Use CAST/CONVERT to return another data type that you want instead.  

http://dev.mysql.com/doc/refman/5.1/en/cast-functions.html

0

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now