12.07.2015 Views

Microsoft Access Tutorial B - Cengage Learning

Microsoft Access Tutorial B - Cengage Learning

Microsoft Access Tutorial B - Cengage Learning

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Tutorial</strong> BFigure B-38Query set-up for time arithmeticFigure B-39 shows the output.Figure B-39Query output for time arithmeticThe output looks right. For example, employee 099-11-3344 was at work from 8:30 a.m.to 4:30 p.m., which is eight hours. But how does the odd expression that follows yield thecorrect answers?([ClockOut] – [ClockIn]) * 24Why wouldn’t the following expression, alone, work?[ClockOut] – [ClockIn]This is the answer: In <strong>Access</strong>, subtracting one time from the other yields the decimalportion of a 24-hour day. Employee 099-11-3344 worked 8 hours, which is one-third of aday, so .3333 would result. That is why you must multiply by 24—to convert to an hourbasis. Continuing with 099-11-3344, 1/3 x 24 = 8.Note that parentheses are needed to force <strong>Access</strong> to do the subtraction first, before themultiplication. Without parentheses, multiplication takes precedence over subtraction. Withthe following expression, ClockIn would be multiplied by 24 and then that value would besubtracted from ClockOut, and the output would be a nonsense decimal number:[ClockOut] – [ClockIn] * 24Delete and Update QueriesThus far, the queries presented in this tutorial have been Select queries. They select certaindata from specific tables, based on a given criterion. You can also create queries to update theoriginal data in a database. Businesses do this often, and in real time. For example, when you<strong>Microsoft</strong> <strong>Access</strong> <strong>Tutorial</strong> 31

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!