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

add integer to time

Status
Not open for further replies.

kiwiCoder

Technical User
Aug 2, 2001
45
NZ
How can I add an Integer value, "Runtime", to a full date field in a VB6 query. StartAt is stored as a full date/time field in an access 2000 db.
What I need is to end up with 2 fields
1: StartAt
2: FinishAt

FinishAt is StartAt + RunTime, this is what I have tried so far.

'Set rsReport = cnDataBaseConnection.Execute("SELECT Film.FilmNumber, Film.FullTitle, Screening.SessionNumber, Screening.CinemaNumber, Screening.StartAt, Film.RunTime, (StartAt, 'HH:MM:SS')as Temp)+(DateAdd(n,Film.RunTime,Temp) )AS EndAt FROM Film INNER JOIN Screening ON Film.FilmNumber = Screening.FilmNumber")
 
By default, Access supports straight arithmetic, and the Dates/Times are simply the left side of the decimal in a double-float and the right side.
So if runtime is seconds, you need to convert to datetime, it's
86400 seconds per day
1 = 1 day in VB
1/86400 = .00001157 = 1 second

So, StartAt + (runtime * .00001157) = FinishAt

--Jim
 
Thanks Jim but I figured it out another way.
Format$(DateAdd('n',[RunTime],[StartAt]), 'DD-MM-YYYY HH:MM:SS') AS Finish
Does just fine
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top