473,378 Members | 1,354 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,378 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 6390
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...
1
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: 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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.