LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-19-2009, 11:59 PM   #1
rajesh84210
Member
 
Registered: Jul 2009
Posts: 53

Rep: Reputation: 15
one question in mysql


Dear All,
I have a question in mysql and iam not very sure if this is the right plcae to post my question.Anyways, my question is

I have two rows where i have two instances of time.(iam posting my table below). I would like to know how to retreive the time difference between the two.I googled n gotta know that TIMESTAMPDIFF function can be used.


+----+--------+----------+----------+-------------------------------------------
| C1 | C2| A2.|...........time...... |.A3..|.A4.|.A5|dst_domain|
+----+--------+----------+----------+--------------------------------------------
| 26 |BYE|200 | OK| 2009-11-18 14:21:18 | 200 |100 |100| 192.168.64.142 |
| 25 |ACK|200 | OK| 2009-11-18 14:21:15 | 100 |200 |200| 192.168.64.75 |

In short i would like to get the time difference between 14:21:18 and 14:21:15
 
Old 11-20-2009, 12:32 AM   #2
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,027

Rep: Reputation: 69
Just curious but what kind of database is that? I'm just now using postgresql and learning the ropes. That database looks interesting. Is it for benchmarking networking latencies?
 
Old 11-20-2009, 02:16 AM   #3
rajesh84210
Member
 
Registered: Jul 2009
Posts: 53

Original Poster
Rep: Reputation: 15
NOt really.. this is related to telephone-billing... any ideas how to retreive the duration(the difference between the two time inputs given)?..
 
Old 11-20-2009, 02:27 AM   #4
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
Many functions available in mysql

TIME FUNCTION
TIMEDIFF
TIMESTAMP FUNCTION
TIMESTAMPADD
TIMESTAMPDIFF
TIME_FORMAT
TIME_TO_SEC
 
Old 11-20-2009, 11:53 AM   #5
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
If they're stored properly as date/time fields, you might just try a simple subtract as well.
DBs usually internally store the date/times as numbers.

The problem would be that they are in separate rows and queries are usually row-based.
You may need some stored procedure for that, or use some custom scripting, rather than the DB.

For what purpose do you need the time diff?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
linux distro question & mysql install question natalie.aloi Linux - Newbie 5 07-19-2009 09:28 PM
Can MySQL log on via SSH/bash? mysql:x:27:101:MySQL Server:/var/lib/mysql:/bin/bash Ujjain Linux - Newbie 2 04-24-2009 03:21 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Newbie 1 06-23-2007 04:35 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 09:44 AM


All times are GMT -5. The time now is 07:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration