MySQL Forums
Forum List  »  Connector/C++

Re: get date/ datetime from database
Posted by: Peter Brawley
Date: March 22, 2022 09:40AM

Connector/C++ returns datetime values as %Y-%m-%d %H:%M:%S strings so you need something like ...

time_t String2time_t( const string& strDateTime ){
tm t;
strptime( strDateTime.c_str(), "%F %T", &t );
return mktime(&t);
}

time_t jt = String2time_t( (string) res->getString("columnName") );

which returns SQLstring, convert it to std::string before passig it on.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: get date/ datetime from database
315
March 22, 2022 09:40AM


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.