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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calculate difference in two times 1

Status
Not open for further replies.

DCCoolBreeze

Programmer
Jul 25, 2001
208
US
I need to calculate the difference between two dates and times. The DateDif works for dates but what about times?
 
Hi

With DateDiff() you can get the difference in years, months, days, minutes etc, see the help file for relevant parameters

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Thanks. I figured out how to do that. But here is another problem. I read in a date/time that looks something like 01/23/2003 19:23:02 as a string from a flat file. When I CDate(sDate) where sDate is 01/23/2003 19:23:02 , I get a conversion error. If I separate the date from the time and do CDate to each individually, it works. Also if I do
sDate = "01/23/2003 19:23:02"
debug.print CDate(sDate)
I get no error. What is up with reading the date/time from an ascii file and then using CDate?
 
I figured it out. Apparently the statement:

dtmDate = CDate(Trim(sDate))

does not work but

dtmDate = CDate(sDate)

does.

There are leading spaces and trailing spaces so I thought I would purge them out...no need. Everything works good now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top