datediff

  • Thread starter Thread starter Brent
  • Start date Start date
B

Brent

Is there a way to use the datediff function to return in results in a
minute:seconds format? Example 03:30 for 3 minutes and 30 seconds.

Brent
 
SomeStringVar = Format(DateDiff("interval",SomeDate1,SomeDate2),"nn:ss")

The reason for "nn" instead of "mm" to denote minutes is because "mm" is
reserved for "months" so "nn" was designated to denote "minutes."

Sam
 
Brent said:
Is there a way to use the datediff function to return in results in a
minute:seconds format? Example 03:30 for 3 minutes and 30 seconds.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

No, because each use of DateDiff() only returns one value type, hours,
minutes, seconds, days, months,... etc. You'd have to do something like
this to get minutes & seconds:

DateDiff("s", #15:00#, #15:30:25#) \ 60 & ":" &
DateDiff("s", #15:00#, #15:30:25#) mod 60

The 1st line will return 30:
The 2nd line will return 25

The final result will be 30:25 (30 minutes & 25 seconds).
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQ9apxoechKqOuFEgEQIOZgCfRzW9Z/Ss5HrvTBag7e/QGyrb0/4An2r9
lGGhAgeL1jmUkad7+gFGcSjS
=Q3Ht
-----END PGP SIGNATURE-----
 
Thanks


Brent
OfficeDev18 via AccessMonster.com said:
SomeStringVar = Format(DateDiff("interval",SomeDate1,SomeDate2),"nn:ss")

The reason for "nn" instead of "mm" to denote minutes is because "mm" is
reserved for "months" so "nn" was designated to denote "minutes."

Sam
 
This is true, and I appologize for any inconvenience. However, you can get
rid of the DateDiff function altogether and use simply

SomeStrVal=Format(varLaterTime - varEarlierTime, "nn:ss")

When I took MGFoster's problem, using #15:30:25# and #15:00#, and put it int
the following Format() statement, as follows,

?Format(#15:30:25# - #15:00#, "nn:ss") (in my Immediate Window)

Access returned "30:25"

which seems to me what you're looking for.

Hope This is More Helpful.

Sam
 
Spoke to soon. I am getting an error when I try and run this. The
information that is in the following fields is in a long date format. ex...
01/01/2006 10:00PM. Is there something I need to do to work with data in
that format?

Brent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top