Wylie said:
I have a numeric field that I am using to convert to hours and minutes. If
the number is 2631070 and I use the following sql query it returns 583 hours
and 70 minutes. Don't think I should have 70 seconds....What have I done
wrong?
SELECT Sum(Statistics.TSeconds) AS SumOfTSeconds,
Sum(Format([Tseconds]\3600,"00")) AS [Hours Ridden], Format(Sum([TSeconds]
Mod 3600\60),"00") AS [Minutes Ridden]
FROM Statistics;
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I believe you'll have better luck putting the Format & division outside
the Sum() function:
SELECT Sum(TSeconds) AS SumOfTSeconds,
Format( SUM(Tseconds) \ 3600, "00") AS [Hours Ridden],
Format( ( SUM(TSeconds) Mod 3600 ) \ 60, "00") AS [Minutes Ridden]
FROM Statistics;
========================================
My calculations (debug window):
? 2631070 \ 3600
730
? (2631070 mod 3600) \ 60
51
The integer divisor has precedence over the mod operator, therefore, put
the mod calculation in parentheses.
Why are you using the Format() function on the result? It is usually a
good idea to let the display function format the result. Down the road
you may wish to use this query as the source of another query and want
to perform a mathematical function on the Hours/Mins. If they are
Formatted, the numbers will be strings & you will have to translate the
string numbers back to numerics.
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/AwUBQigS34echKqOuFEgEQKpzgCdFXl0QZXLv4xKwveHco8fUyag96YAn1qb
SQXyJkJkca8UvAQ5Lz5mlh2u
=Rsrj
-----END PGP SIGNATURE-----