Time Calculations

B

Bob G

Not sure If I need to post this here or in Word NG. (Will
probably do both) Trying to calculate time difference
(End time - start time) in a field merged from Access 2000
to Word 2000 document. Simple {= endtime-starttime}
doesn't work. Any thoughts?
 
W

Wayne Morgan

Have Word connect to a query in Access, not directly to the table. In the
query you can make a calculated field. Use the DateDiff function to get your
time difference.
 
G

Guest

Did that. Access expresses the difference as hh:mm, but
when it goes into Word, I get a fraction of 24 hrs. Tried
\@ "HH:Mm" switch, to no avail. Any thoughts?
 
W

Wayne Morgan

Access deals with dates and times as numbers. The Format function should
return text. Try wrapping the calculation with Format even though it already
shows, by default, the way you want in Access. This hopefully will change it
to text so that Word will handle it properly. If that doesn't work, perhaps
wrapping it in CStr will.

I just tried the following query as a data source for Word and received the
time as 01:15.

SELECT Format(#16:0:0#-#14:45:0#,"Short Time") AS TimeTest, Table1.Field1
FROM Table1;

I also tried wrapping the Format with CStr and that appeared to work also.
CStr(Format(#16:0:0#-#14:45:0#,"Short Time"))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top