Calculate time based on an integer in another field

A

Arnold R

I am trying to generate a field in a table that is a time (e.g.,8:15 AM).
This time is to be calculated from another field which contains an integer.
I want the time generated to be 7:30 AM plus 7.5 minutes times the number in
the other field (group number). Can anyone tell me how to accomplish this?

Thanks for all help.
 
J

John Nurick

Hi Arnold,

I assume it's a calculated field you have in mind; there's no point
storing data that can easily be calculated whenever its needed.

If the time is stored in a date/time field, use something like this as a
calculated field in a query, or as the data source of a textbox on a
form or report:

DateAdd("n", 7.5 * [GroupNumber], [TimeField])

If the time is stored in text field, try

DateAdd("n", 7.5 * [GroupNumber], CDate([TimeField]))
 
A

Arnold R

John,

Thank you so much. That works perfectly. When I first looked at your reply
I was going to write back and ask what the "n" meant. Then I tried to look
up the adddate function in help. Unfortunately, the only thing there is an
example and there is no explanation of the function's syntax or effect. I
surmised that the n meant minutes. Can you point me to someplace that
explains the function? Your help is much appreciated.

Thanks again.

John Nurick said:
Hi Arnold,

I assume it's a calculated field you have in mind; there's no point
storing data that can easily be calculated whenever its needed.

If the time is stored in a date/time field, use something like this as a
calculated field in a query, or as the data source of a textbox on a
form or report:

DateAdd("n", 7.5 * [GroupNumber], [TimeField])

If the time is stored in text field, try

DateAdd("n", 7.5 * [GroupNumber], CDate([TimeField]))


I am trying to generate a field in a table that is a time (e.g.,8:15 AM).
This time is to be calculated from another field which contains an integer.
I want the time generated to be 7:30 AM plus 7.5 minutes times the number in
the other field (group number). Can anyone tell me how to accomplish this?

Thanks for all help.
 
D

Douglas J. Steele

Even though this reference says it's for Access 97, it applies to all
versions:

http://msdn.microsoft.com/archive/en-us/office97/html/output/F1/d6/S5B206.asp

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Arnold R said:
John,

Thank you so much. That works perfectly. When I first looked at your
reply
I was going to write back and ask what the "n" meant. Then I tried to
look
up the adddate function in help. Unfortunately, the only thing there is
an
example and there is no explanation of the function's syntax or effect. I
surmised that the n meant minutes. Can you point me to someplace that
explains the function? Your help is much appreciated.

Thanks again.

John Nurick said:
Hi Arnold,

I assume it's a calculated field you have in mind; there's no point
storing data that can easily be calculated whenever its needed.

If the time is stored in a date/time field, use something like this as a
calculated field in a query, or as the data source of a textbox on a
form or report:

DateAdd("n", 7.5 * [GroupNumber], [TimeField])

If the time is stored in text field, try

DateAdd("n", 7.5 * [GroupNumber], CDate([TimeField]))


I am trying to generate a field in a table that is a time (e.g.,8:15
AM).
This time is to be calculated from another field which contains an
integer.
I want the time generated to be 7:30 AM plus 7.5 minutes times the
number in
the other field (group number). Can anyone tell me how to accomplish
this?

Thanks for all help.
 
A

Arnold R

Thanks very much.

Douglas J. Steele said:
Even though this reference says it's for Access 97, it applies to all
versions:

http://msdn.microsoft.com/archive/en-us/office97/html/output/F1/d6/S5B206.asp

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Arnold R said:
John,

Thank you so much. That works perfectly. When I first looked at your
reply
I was going to write back and ask what the "n" meant. Then I tried to
look
up the adddate function in help. Unfortunately, the only thing there is
an
example and there is no explanation of the function's syntax or effect. I
surmised that the n meant minutes. Can you point me to someplace that
explains the function? Your help is much appreciated.

Thanks again.

John Nurick said:
Hi Arnold,

I assume it's a calculated field you have in mind; there's no point
storing data that can easily be calculated whenever its needed.

If the time is stored in a date/time field, use something like this as a
calculated field in a query, or as the data source of a textbox on a
form or report:

DateAdd("n", 7.5 * [GroupNumber], [TimeField])

If the time is stored in text field, try

DateAdd("n", 7.5 * [GroupNumber], CDate([TimeField]))


On Fri, 13 May 2005 21:40:01 -0700, "Arnold R"

I am trying to generate a field in a table that is a time (e.g.,8:15
AM).
This time is to be calculated from another field which contains an
integer.
I want the time generated to be 7:30 AM plus 7.5 minutes times the
number in
the other field (group number). Can anyone tell me how to accomplish
this?

Thanks for all help.
 
Top