By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,293 Members | 1,382 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,293 IT Pros & Developers. It's quick & easy.

Incrementing time from an input time?

P: n/a
I am working on an application in which the end user will enter a
time, Say 3:00 PM, and a number, say 5

I want to create a number of records (5) as follows,

3:00:00
3:00:01
3:00:02
3:00:03
3:00:04

etc.

I created an expression that creates the records but I can't figure
out how to get them to increment.

I tried adding #00:00:01# but access converts that to #12:00:00 AM#

Any help would be greatly appreciated.
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Shyguy wrote:
I am working on an application in which the end user will enter a
time, Say 3:00 PM, and a number, say 5

I want to create a number of records (5) as follows,

3:00:00
3:00:01
3:00:02
3:00:03
3:00:04

etc.

I created an expression that creates the records but I can't figure
out how to get them to increment.

I tried adding #00:00:01# but access converts that to #12:00:00 AM#

Any help would be greatly appreciated.

See DateAdd in help

Nov 12 '05 #2

P: n/a
Easiest do create the records with code, using a loop:

Dim rs As DAO.Recordset
Dim dtStart As Date
Dim lngMinutes As Long

Set rs = dbEngine(0)(0).OpenRecordset("YourTableNameHere")
stStart = #15:00:00# '3pm.
For lngMinutes = 0 To 5
rs.AddNew
rs![YourTimeField] = DateAdd("n", dtStart, lngMinutes)
'any other fields on separate lines here.
rs.Update
Next
rs.Close
Set rs = Nothing

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Shyguy" <Sh****@shytown.com> wrote in message
news:ek********************************@4ax.com...
I am working on an application in which the end user will enter a
time, Say 3:00 PM, and a number, say 5

I want to create a number of records (5) as follows,

3:00:00
3:00:01
3:00:02
3:00:03
3:00:04

etc.

I created an expression that creates the records but I can't figure
out how to get them to increment.

I tried adding #00:00:01# but access converts that to #12:00:00 AM#

Any help would be greatly appreciated.

Nov 12 '05 #3

P: n/a
On Thu, 29 Apr 2004 06:04:02 GMT, Salad <oi*@vinegar.com> wrote:
Shyguy wrote:
I am working on an application in which the end user will enter a
time, Say 3:00 PM, and a number, say 5

I want to create a number of records (5) as follows,

3:00:00
3:00:01
3:00:02
3:00:03
3:00:04

etc.

I created an expression that creates the records but I can't figure
out how to get them to increment.

I tried adding #00:00:01# but access converts that to #12:00:00 AM#

Any help would be greatly appreciated.

See DateAdd in help


Thanks very much,

DateAdd did the trick..
Nov 12 '05 #4

P: n/a
Hi,

Would this function be of any use? (copied from the Help files).
TimeSerial Function
Returns a Variant (Date) containing the time for a specific hour, minute,
and second.

Syntax

TimeSerial(hour, minute, second)

The TimeSerial function syntax has these named arguments

Part Description
hour Required; Variant (Integer). Number between 0 (12:00 A.M.) and 23
(11:00 P.M.), inclusive, or a numeric expression
minute Required; Variant (Integer). Any numeric expression.
second Required; Variant (Integer). Any numeric expression.

"Shyguy" <Sh****@shytown.com> wrote in message
news:ek********************************@4ax.com...
I am working on an application in which the end user will enter a
time, Say 3:00 PM, and a number, say 5

I want to create a number of records (5) as follows,

3:00:00
3:00:01
3:00:02
3:00:03
3:00:04

etc.

I created an expression that creates the records but I can't figure
out how to get them to increment.

I tried adding #00:00:01# but access converts that to #12:00:00 AM#

Any help would be greatly appreciated.

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.