W
Wes via AccessMonster.com
Have a long integer field that represents seconds. I use a query to total
seconds. Then in the query under SQL I put a format statement to convert
total seconds to days hh:nn:ss. This works very well, but the format
statement is long and confusing to read.
FORMAT$([Sum OF Duration]\86400, "0")&" day "&FORMAT$(([Sum OF Duration]MOD
86400)\3600,"00")&":"&FORMAT$(([Sum OF Duration]MOD 3600)\60,"00")&":"&FORMAT
$([Sum OF Duration]MOD 60,"00") AS Total_Air_Time
See what I mean?
So, I thought about appling a function to do this. Started writing the
function and tested it and an error comes up that has me stumped.
Wrong number of arugments used with function in query expression 'dhns([secs])
'.
So my first question is - Can I use a function to format a field?
Second question - What and how many arguments is the function looking for.
Here is the function code. I realize that I still have to add some lines to
format the result, but was testing the code when the argument error came up.
Public Function dhns()
Dim myDay As Integer
Dim myHours As Integer
Dim myMins As Integer
Dim mySecs As Integer
myDay = (sumofduration) \ 86400
myHours = myDay Mod 86400 \ 3600
myMins = myHours Mod 3600 \ 60
mySecs = mymymins Mod 60
End Function
seconds. Then in the query under SQL I put a format statement to convert
total seconds to days hh:nn:ss. This works very well, but the format
statement is long and confusing to read.
FORMAT$([Sum OF Duration]\86400, "0")&" day "&FORMAT$(([Sum OF Duration]MOD
86400)\3600,"00")&":"&FORMAT$(([Sum OF Duration]MOD 3600)\60,"00")&":"&FORMAT
$([Sum OF Duration]MOD 60,"00") AS Total_Air_Time
See what I mean?
So, I thought about appling a function to do this. Started writing the
function and tested it and an error comes up that has me stumped.
Wrong number of arugments used with function in query expression 'dhns([secs])
'.
So my first question is - Can I use a function to format a field?
Second question - What and how many arguments is the function looking for.
Here is the function code. I realize that I still have to add some lines to
format the result, but was testing the code when the argument error came up.
Public Function dhns()
Dim myDay As Integer
Dim myHours As Integer
Dim myMins As Integer
Dim mySecs As Integer
myDay = (sumofduration) \ 86400
myHours = myDay Mod 86400 \ 3600
myMins = myHours Mod 3600 \ 60
mySecs = mymymins Mod 60
End Function