Date and Time formating

G

Guest

First of all, I'd like to thank all.
I have this formula which works well

CDate([Delivery Date] & " " & [Delivery Time])-CDate([Arrival Date] & " " &
[Arrival Time])

I get a values as double precision numbers like so:
01/01/2005 13:00 01/02/2005 14:05 "1.04513888889051"
My question:
I want to format as: X day X hours X minutes? Not, the decimal equivalent.
Any thoughts, thanks again.
 
G

Guest

No disrespect to you, but can't I just use the format function without
writing all this code?

Duane Hookom said:
Doug Steele has a nice function for doing this at
http://www.accessmvp.com/djsteele/Diff2Dates.html.

--
Duane Hookom
MS Access MVP


bladelock said:
First of all, I'd like to thank all.
I have this formula which works well

CDate([Delivery Date] & " " & [Delivery Time])-CDate([Arrival Date] & " "
&
[Arrival Time])

I get a values as double precision numbers like so:
01/01/2005 13:00 01/02/2005 14:05 "1.04513888889051"
My question:
I want to format as: X day X hours X minutes? Not, the decimal equivalent.
Any thoughts, thanks again.
 
D

Duane Hookom

You could use a complex expression and then create another complex
expression elsewhere and maybe again in another report. Or, you could copy
and paste the code into a module and keep your expressions very simple.

--
Duane Hookom
MS Access MVP
--

bladelock said:
No disrespect to you, but can't I just use the format function without
writing all this code?

Duane Hookom said:
Doug Steele has a nice function for doing this at
http://www.accessmvp.com/djsteele/Diff2Dates.html.

--
Duane Hookom
MS Access MVP


bladelock said:
First of all, I'd like to thank all.
I have this formula which works well

CDate([Delivery Date] & " " & [Delivery Time])-CDate([Arrival Date] & "
"
&
[Arrival Time])

I get a values as double precision numbers like so:
01/01/2005 13:00 01/02/2005 14:05 "1.04513888889051"
My question:
I want to format as: X day X hours X minutes? Not, the decimal
equivalent.
Any thoughts, thanks again.
 
G

Guest

ok, so I copy this code in the module section and then in my report just add
the expression to the text box correct?

Duane Hookom said:
You could use a complex expression and then create another complex
expression elsewhere and maybe again in another report. Or, you could copy
and paste the code into a module and keep your expressions very simple.

--
Duane Hookom
MS Access MVP
--

bladelock said:
No disrespect to you, but can't I just use the format function without
writing all this code?

Duane Hookom said:
Doug Steele has a nice function for doing this at
http://www.accessmvp.com/djsteele/Diff2Dates.html.

--
Duane Hookom
MS Access MVP


First of all, I'd like to thank all.
I have this formula which works well

CDate([Delivery Date] & " " & [Delivery Time])-CDate([Arrival Date] & "
"
&
[Arrival Time])

I get a values as double precision numbers like so:
01/01/2005 13:00 01/02/2005 14:05 "1.04513888889051"
My question:
I want to format as: X day X hours X minutes? Not, the decimal
equivalent.
Any thoughts, thanks again.
 
D

Duane Hookom

Copy the code into a general module and save the module with a name like
"modDateTimeCalcs". You can then use the function like you would use any
built-in function in Access.

--
Duane Hookom
MS Access MVP
--

bladelock said:
ok, so I copy this code in the module section and then in my report just
add
the expression to the text box correct?

Duane Hookom said:
You could use a complex expression and then create another complex
expression elsewhere and maybe again in another report. Or, you could
copy
and paste the code into a module and keep your expressions very simple.

--
Duane Hookom
MS Access MVP
--

bladelock said:
No disrespect to you, but can't I just use the format function without
writing all this code?

:

Doug Steele has a nice function for doing this at
http://www.accessmvp.com/djsteele/Diff2Dates.html.

--
Duane Hookom
MS Access MVP


First of all, I'd like to thank all.
I have this formula which works well

CDate([Delivery Date] & " " & [Delivery Time])-CDate([Arrival Date]
& "
"
&
[Arrival Time])

I get a values as double precision numbers like so:
01/01/2005 13:00 01/02/2005 14:05 "1.04513888889051"
My question:
I want to format as: X day X hours X minutes? Not, the decimal
equivalent.
Any thoughts, thanks again.
 
G

Guest

Just one more question, if you don't mind.

I put this in my report and it worked fine, thanks:
=Diff2Dates("hns",#1/26/2002 1:23:01 PM#,#1/26/2002 8:10:34 PM#)

Now, how do I replace the old calucation into this new one Using the top
syntax

CDate([Delivery Date] & " " & [Delivery Time])-CDate([Arrival Date] & " " &
[Arrival Time])

Delivery Date & Arrival Date="Date Format"
Delivery Time & Arrival Time="Military Time Format"

Would it look like this:

=Diff2Dates("hns",[Delivery Date] & " " & [Delivery Time]), ([Arrival Date]
& " " &
[Arrival Time])

Thanks again
 
D

Duane Hookom

You should be able to just add the time to the date:
=Diff2Dates("hns",[Delivery Date] + [Delivery Time], [Arrival Date]+
[Arrival 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