• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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