Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Difference

Status
Not open for further replies.

EzehM

Programmer
Feb 27, 2003
86
GB
I have 2 dates stored as strings in the following format:

YYYYMMDDHHMMSS

20051012130628

20051012130633

How can I write a function to tell me the difference in seconds.

Thanks
 
You create a function as you would normally do, with input parameters (2 fields for the dates), output parameter(to give you back the seconds interval), define these types as appropriate, and then on the body function you convert each date to seconds.
Then you subtract one from the other.


I am pretty sure that you know how to convert dates to seconds.


Once you have some code and if you still have problems please come back with specific problems.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Thanks, I managed to knock something together (A long winded function). I thought there must be a single API that could do it. Not sure if there is?
 
Here's a simple solution.

Dim datDate1 As Date
Dim datDate2 As Date
Dim lngSeconds As Long

datDate1 = CDate("2005/10/12")
datDate1 = datDate1 + TimeSerial(13, 6, 28)

datDate2 = CDate("2005/10/12")
datDate2 = datDate2 + TimeSerial(13, 6, 33)

lngSeconds = DateDiff("s", datDate1, datDate2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top