Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

adding time when i don't care about date 1

Status
Not open for further replies.

imarosel

Technical User
Jun 23, 2005
149
US
Dim offerTime As Date
Dim i As Integer
Dim temp As String
offerTime = #12:00:00 AM#
temp = ""

For i = 1 To 24
temp = temp & DateAdd("h", i, offerTime) & " ,"
Next i

Debug.Print temp

output
1:00:00 AM ,2:00:00 AM ,3:00:00 AM ,4:00:00 AM ,5:00:00 AM ,6:00:00 AM ,7:00:00 AM ,8:00:00 AM ,9:00:00 AM ,10:00:00 AM ,11:00:00 AM ,12:00:00 PM ,1:00:00 PM ,2:00:00 PM ,3:00:00 PM ,4:00:00 PM ,5:00:00 PM ,6:00:00 PM ,7:00:00 PM ,8:00:00 PM ,9:00:00 PM ,10:00:00 PM ,11:00:00 PM ,[highlight]12/31/1899[/highlight]

I will add 24 or less, not 24 every time.

I think this is because there is no date associated with the time. I don't want to associate a date.
 
And what about this ?
For i = 1 To 24
temp = temp & Format(offerTime + i/24, "Long Time") & " ,"
Next i

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I don't know how you knew that. I would not have thought to try that, but it works. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top