473,320 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Difference between two timestamps

How to calculate time difference between two time stamps in terms of hours , minutes, seconds collectively
Aug 6 '07 #1
7 6389
RedSon
5,000 Expert 4TB
How to calculate time difference between two time stamps in terms of hours , minutes, seconds collectively
You need to provide more information before we can help you. Or I can provide a general answer. You take the earlier time stamp and subtract if from the later time stamp.
Aug 6 '07 #2
Hi i too have the same problem.

I have a small forum system. And when user posts any article i am going to store it to the database along with current date. When Other users look at this article, I wants to show them the time lapsed after posting the article.

Means i wants subtract current time from the time stored in database and display the string such as "Article posted before 1 year 2 months 2 days 10 Hours 5 minutes and 3 seconds back".

Can any one help me please.
Aug 28 '07 #3
debasisdas
8,127 Expert 4TB
Use simple substraction and then go for conversions required if any.
Aug 28 '07 #4
RedSon
5,000 Expert 4TB
Use simple substraction and then go for conversions required if any.
Yes this is all pretty simple. and debasisdas said it correctly. All you need to do is subtract the first date from the second date. It is a trivial problem.
Aug 28 '07 #5
JosAH
11,448 Expert 8TB
Yes this is all pretty simple. and debasisdas said it correctly. All you need to do is subtract the first date from the second date. It is a trivial problem.
It is not if you want the output of the difference as asked for in post#3, i.e.
a 30 days difference would be less than a month if the last timestamp would be
mar-31-2007, but it would be a bit more than a month if the last timestamp would
be mar-01-2007.

That Gregorian calendar is a mess if you'd ask me ;-)

kind regards,

Jos
Aug 28 '07 #6
RedSon
5,000 Expert 4TB
It is not if you want the output of the difference as asked for in post#3, i.e.
a 30 days difference would be less than a month if the last timestamp would be
mar-31-2007, but it would be a bit more than a month if the last timestamp would
be mar-01-2007.

That Gregorian calendar is a mess if you'd ask me ;-)

kind regards,

Jos
The difference in time calculation is trivial. Trying to convert that difference in days months and years is a completely different matter. Best to use a Sidereal calendar.
Aug 29 '07 #7
JosAH
11,448 Expert 8TB
The difference in time calculation is trivial. Trying to convert that difference in days months and years is a completely different matter. Best to use a Sidereal calendar.
Erm, yes, that's what I said ;-)

kind regards,

Jos
Aug 29 '07 #8

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

Similar topics

7
by: lkrubner | last post by:
This might be an idiot question, but how do you group by timestamps by date? I mean, given a large number of timestamps, spanning many months, how do grab them and say how many are from each day?...
4
by: Hans Gruber | last post by:
Hi all, I have been struggling with a problem all day, I have been unable to come up with a working solution. I want to write a function which takes 2 unix timestamps and calculates the...
6
by: Bjørn T Johansen | last post by:
I need to compute the difference of Time fields, in the format HHMM. Is it possible to do the math in the Select? Regards, BTJ --...
5
by: Robert Schuldenfrei | last post by:
Dear NG, I have not heard from anyone about a good book that deals with the concurrency issue in SQL Server using C#. I have PROMISED Nick I would not use record locking and I have used an old...
2
by: Chumma Dede | last post by:
Hi, I need to code a DLL in .NET which logs the response times for our asp.net multi-tier application. The problem is we need to log the timestamps at multiple stages in a process lifecycle...
4
by: Craig G | last post by:
im not too sure how i should be storing the SQL2000 timestamps basically i return a dataset which is used to populate an editable grid. this dataset contains the timestamp. how should i be...
1
by: Erwin Van de Velde | last post by:
Hi, I'm building a central logging system for security applications as my master thesis, but I've run into some troubles: Different applications make database logs using different formats: -...
7
by: fjm | last post by:
Hi all, I have a problem getting a correct result with my sql code and figured I would see if anybody could help. I have two fields in a table that have timestamps. I want to find the...
5
by: Julius | last post by:
Hej dudes, I need to calc the difference between two timestamps / dates ... For example what i need to calculate: Date 1: 2007.11.06 - 20:13:04 Date 2: 2007.11.07 - 21:13:04 Difference:...
6
by: xkenneth | last post by:
All, Just a quick question. I want to be able to have a data structure that organizes data (timestamps I'm working with) sequentially, so that i can easily retrieve the first x amount of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.