MySQL Forums
Forum List  »  Connector/C++

Selecting a date column
Posted by: Brian Pontarelli
Date: September 24, 2009 08:31PM

I'm stuck on what appears to be a simple case. Coming from the JDBC side of things, selecting a date column from a table is simple and you can fetch the value from the ResultSet using the getDate methods. However, there are no date methods on the C++ API. Here's what happens and what I'm trying to solve:

- Calling the getUInt methods on ResultSet return only the year of the date
- I'm trying REALLY hard to stay SQL 99 compliant
- I can use the unix_timestamp date function, but that breaks my SQL 99 compliance

The SQL I'm using that is SQL 99 compliant is:

  select modified_date from foo_bar

If I make this call:

  time_t date = resultSet->getUInt("modified_date");

The value is just the year part (i.e. 2009). The only way I can see to fix it is breaking SQL 99 compliance and using a select like this:

  select unix_timestamp(modified_date) from foo_bar

This works using the getUInt methods. However, the code is abstracted in a such a manner that I can hit any database as by just plugging in a different driver (very JDBC like).

Is there any way to select a date column and get the value back from the C++ API without using a the unix_timestamp function?

Options: ReplyQuote

Written By
Selecting a date column
September 24, 2009 08:31PM
September 25, 2009 09:46AM
September 25, 2009 10:43AM
September 28, 2009 01:04AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.