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

Access 2007:Calculating time elapsed based on a date 1

Status
Not open for further replies.

Evilyvy

Technical User
Sep 3, 2008
2
US
Hi all,
I am new to access 2007 and I am trying to create a field in a query that will return total elapsed hours worked based on their hire date.

This returns total days:

Hours Worked: Int(DateDiff("d",[Vendors]![Hire Date],Date()))

Is there a way to format this into hours?
 
How are ya Evilyvy . . .

Hmmmm ... So why havn't you tried hours?
Code:
[blue]   Hours Worked: DateDiff("[purple][b]h[/b][/purple]",[Vendors]![Hire Date],Date())[/blue]

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Or assuming they haven't worked 24 hours per day:

Code:
intHoursWorked=Int(DateDiff("d",[Vendors]![Hire Date],Date()))*8

Assuming of course an 8 hour working day this will give an approximation... Depending of course on what time of day you run it :)

JB
 
oh, and you may want to do something funky to discount weekends too - perhaps datediff in weeks and multiply by 16 (Hours NOT worked as it was weekend) and subtracting that from the result above...

JB
 
there are a couple of approaches to this in FAQs. Including Work day hours, Holidays, weekends ...



MichaelRed


 
Hey Guys,
Thanks for your help. JBinQLD your code worked perfectly! I've spent 2 days looking through all sorts of forums looking for an answer.
 
No drama, sometimes it's easy to overlook the obvious! Good luck with your project.

JB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top