Re: Need help to query with timestamp in C++

2008-08-15 Thread Kandy Wong
Hi Dusan, Thank you so much. It works! Kandy > Hi Kandy, > > this could be the query you are looking for. It should return record > with the closest timestamp to your required time: > > (SELECT TIMEDIFF('20080815091907', timestamp_column) AS diff, t.* FROM > table1 t > WHERE timestamp_column <=

RE: Need help to query with timestamp in C++

2008-08-15 Thread Jerry Schwartz
y Wong [mailto:[EMAIL PROTECTED] >Sent: Friday, August 15, 2008 2:36 AM >To: Saul Bejarano >Cc: mysql@lists.mysql.com >Subject: Re: Need help to query with timestamp in C++ > >Hi Saul, > >I need to use C++ and I'm not writing a web application. >Thanks anyway. > >

Re: Need help to query with timestamp in C++

2008-08-15 Thread Warren Young
Kandy Wong wrote: And what is the good connector (C++ to MySQL) to use? MySQL++ (http://tangentsoft.net/mysql++/) has native Date, Time, and DateTime data types. You can convert to these types implicitly: mysqlpp::DateTime dt = row["my_column"]; Row::operator[] doesn't return Date

Re: Need help to query with timestamp in C++

2008-08-15 Thread walter harms
Kandy Wong wrote: > Hi Saul, > > I need to use C++ and I'm not writing a web application. > Thanks anyway. you can do something like: select min(abs(timediff("",timestamp))) from where ; if you use the libmysql you can get the result as strings back (the method i prefer) and convert the

Re: Need help to query with timestamp in C++

2008-08-15 Thread DuĊĦan Pavlica
Hi Kandy, this could be the query you are looking for. It should return record with the closest timestamp to your required time: (SELECT TIMEDIFF('20080815091907', timestamp_column) AS diff, t.* FROM table1 t WHERE timestamp_column <= '20080815091907' ORDER BY timestamp_column DESC LIMIT 1 )

Re: Need help to query with timestamp in C++

2008-08-14 Thread Kandy Wong
Hi Saul, I need to use C++ and I'm not writing a web application. Thanks anyway. Kandy > I have done queries to the database in PHP with variables like month but > easily can select from a range of time and data to produce the same > results, the output goes directly to the web so if that is wha

Re: Need help to query with timestamp in C++

2008-08-14 Thread Saul Bejarano
I have done queries to the database in PHP with variables like month but easily can select from a range of time and data to produce the same results, the output goes directly to the web so if that is what you are seeking for, I can help with PHP. Saul Kandy Wong wrote: Hi, I need to write a

Need help to query with timestamp in C++

2008-08-14 Thread Kandy Wong
Hi, I need to write a C++ program in a Linux environment to query with a timestamp. The user will only provide with an approximate time so I'd like to know how can I write a program or a query to return the closest data. The followings are the timestamp in the MySQL database: | 2008-08-05 03:56:0