dbTalk Databases Forums  

how to convert time_t to ANSI SQL format DateTime string(2005-05-02 10:09:09).

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss how to convert time_t to ANSI SQL format DateTime string(2005-05-02 10:09:09). in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
zlf
 
Posts: n/a

Default how to convert time_t to ANSI SQL format DateTime string(2005-05-02 10:09:09). - 05-01-2005 , 09:47 PM






Hi,
May anyone tell me how to change datetime with Unix format(Mon May 02
10:09:09 2005) to ANSI SQL format(2005-05-02 10:09:09) or directly convert
time_t to ANSI SQL format string.
I am developing a log program using C++ and Mysql. I want to inserting
time data into a DateTime-type column. Mysql requires datetime with ANSI SQL
format. However ctime ( time_t * time ) returns value like 'Mon May 02
10:09:09 2005'(datetime with Unix format).
thx
zlf




--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
Chris Frey
 
Posts: n/a

Default Re: how to convert time_t to ANSI SQL format DateTime string(2005-05-02 10:09:09). - 05-02-2005 , 01:02 AM






On Mon, May 02, 2005 at 10:16:56AM +0800, zlf wrote:
Quote:
Hi,
May anyone tell me how to change datetime with Unix format(Mon May 02
10:09:09 2005) to ANSI SQL format(2005-05-02 10:09:09) or directly convert
time_t to ANSI SQL format string.
I am developing a log program using C++ and Mysql. I want to inserting
time data into a DateTime-type column. Mysql requires datetime with ANSI SQL
format. However ctime ( time_t * time ) returns value like 'Mon May 02
10:09:09 2005'(datetime with Unix format).
This thread might help:
http://lists.mysql.com/plusplus/3739

If you're building a query, use a mysqlpp:ateTime object and then just
do: query << "SELECT ... WHERE something = '" << DateTime << "'";

- Chris


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
zlf
 
Posts: n/a

Default Re: how to convert time_t to ANSI SQL format DateTime string(2005-05-02 10:09:09). - 05-05-2005 , 08:43 PM



Problem solved by using strftime(). Thank you

"Earl Miles" <merlin (AT) logrus (DOT) com> ??????:42764FF8.2050501 (AT) logrus (DOT) com...
Quote:
zlf wrote:
Hi,
May anyone tell me how to change datetime with Unix format(Mon May 02
10:09:09 2005) to ANSI SQL format(2005-05-02 10:09:09) or directly
convert time_t to ANSI SQL format string.
I am developing a log program using C++ and Mysql. I want to
inserting time data into a DateTime-type column. Mysql requires datetime
with ANSI SQL format. However ctime ( time_t * time ) returns value like
'Mon May 02 10:09:09 2005'(datetime with Unix format).
thx
zlf

use strftime() which lets you format a date however you want.

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe:
http://lists.mysql.com/plusplus?unsu...us@m.gmane.org





--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.