473,497 Members | 2,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

finding Datetime difference in seconds

20 New Member
Hi,
I want to find the the exact difference between two dates in seconds through MySQL query.
Version: 4.1
Platform: Linux
Source code:
>select datediff('2007-01-09 10:24:46','2007-01-09 10:23:46')
The datediff() function has only two datetime parameters and returns the difference in days.Instead if i want the value to be returned in seconds,what is the possible way??
Jan 9 '07 #1
5 74201
ronverdonk
4,258 Recognized Expert Specialist
Hi,
I want to find the the exact difference between two dates in seconds through MySQL query.
Version: 4.1
Platform: Linux
Source code:
>select datediff('2007-01-09 10:24:46','2007-01-09 10:23:46')
The datediff() function has only two datetime parameters and returns the difference in days.Instead if i want the value to be returned in seconds,what is the possible way??
Use the TIMEDIFF and TIME_TO_SEC functions, as in:
Expand|Select|Wrap|Line Numbers
  1. SELECT TIME_TO_SEC(TIMEDIFF('2007-01-09 10:24:46','2007-01-09 10:23:46'));
Ronald :cool:
Jan 9 '07 #2
prileep
20 New Member
I am really thankful to u with the solution u given for this. I could achieve this by some other twisted method. But your solution helped me to calculate in subqueries itself,because iwanted to calculate in subquery.
Jan 10 '07 #3
ronverdonk
4,258 Recognized Expert Specialist
We learn every day! Come back when you have more questions.

Ronald :cool:
Jan 10 '07 #4
preejith
3 New Member
Use the TIMEDIFF and TIME_TO_SEC functions, as in:
Expand|Select|Wrap|Line Numbers
  1. SELECT TIME_TO_SEC(TIMEDIFF('2007-01-09 10:24:46','2007-01-09 10:23:46'));
Ronald :cool:
thank you...... you are great
Nov 21 '07 #5
morsol
1 New Member
Note that the solution only works when the datetimes are less than 35 days apart!
TIMEDIFF retuns a TIME datatype, and the max value for TIME is 838:59:59 hours (=34,96 days)
Jan 28 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2842
by: Ed | last post by:
Hi, I have 2 sets of XML documents. XML1 is: <Root> <Node1>111</Node1> <Node2>222</Node2> <Node3>333</Node3> <Node4>
5
11502
by: Larry Bird | last post by:
I want to use TimeSpan to determine the differences between two date to include time. My input data is in the following format: 12/25/2004 12:23:00 AM or 01/05/2005 11:59:00 PM How do I get...
2
1919
by: Chris Leffer | last post by:
Hi. My application reads a table that stores data as time, eg: 02:17:31 I need to read this value and convert it to an integer, representing the total number of seconds. At this moment I am...
1
1306
by: JIM.H. | last post by:
Hello I have TextBox1 this keeps date and time information and I need to compare this DateTime with the current DateTime and find difference in hour. How can I do this in VB.Net? Thanks,
1
3014
by: JIM.H. | last post by:
Hello I have TextBox1 this keeps date and time information and I need to compare this DateTime with the current DateTime and find difference in hour. How can I do this in VB.Net? Thanks,
1
7841
by: indiarocks | last post by:
This is probably a very basic question, how do I find out the difference between two system time. I tried x1 = t1.clock x2 = t2.clock x2 - x1 doesn't seem to give me the difference. ...
4
2966
by: pks83 | last post by:
In MSSQL I am using datetime as the column type and trying to execute the below mentioned query select time from tickets where ticket_id = '1'; when i execute the query on sql manager window it...
1
2603
rizwan6feb
by: rizwan6feb | last post by:
I am developing an application in VB.net 2005 that synchronizes two mysql databases of same structure. I have done most of the work but having problem in finding the difference in records in 2...
2
6239
by: maxin | last post by:
Hi, I have some date time in xml file: <?xml version="1.0"?> <ProductionPerformance> <ActualStartTime>2008-12-07T01:00:00</ActualStartTime>...
0
7121
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6993
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7162
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7197
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.