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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on a text based time addition problem

Status
Not open for further replies.

trekwars2000

Technical User
Apr 18, 2006
4
US
Assuming I have a time column in the form of an 8 character text format (24 hour time, ex: 15:23:08) and I want to add an offset of any time, how would I write the query? I can do it easily in excel but access is giving me a problem. Here is what I came up with but I get an error:

Assuming I want to add say a 1:35:34 time offset to my data:

IIF(LEN(hour(TimeValue([time])+TimeValue("01:35:34")))=2,TimeValue([time])+TimeValue("01:35:34"),"0"&hour(TimeValue([time])+TimeValue("01:35:34")))&":"&(minute portion)&":"&(second portion)

Is this correct syntax? I cannot get it to work.

Thanks.
 
It looks like you want to add time value B to time value A where time value A is a text field. If so, try:
TimeValue([TimeValueA]) + #01:34:34#

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Then
Code:
Format ( TimeValue([TimeValueA]) + #01:34:34#, "hh:nn:ss" )
but note that you are implicitly using Date Time Stamps that are restricted to a maximum of 23:59:59. For example
Code:
? Format ( TimeValue("23:42:05") + #01:34:34#, "hh:nn:ss" )
yields 01:16:39

and not the 25:16:39 that you may have wanted.




[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top