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

Calc GeneralDate Lapse time w/out fractions

Status
Not open for further replies.

kevinwilson

Technical User
Jul 13, 2001
33
US
Aloha,
I would appreciate whatever help anyone can provide on this one. Here's my problem: I have two fields [ReceivedDate] and [ShippedDate], both are "General Date" format. I would like to calculate the amount of days it took for the item to be shipped. The code below works fine as long as the user doesn't add hours, minutes, and seconds to the equation.

If the user enters dates only then it works, 3/15/2002-3/10/2002="5 days to ship".
However if the user enters date/time then the code below doesn't work, 3/15/2002 9:52:33 AM - 3/10/2002="*fraction* days to ship".

Seems simple enough, this is what I did:
Created a text box and added this code "=[ShippedDate]-[ReceivedDate]&" days to ship"". This works for date fields but when the user enters dates/time then the returned results are displayed in fractions.

It's too late for me to change the date/time format for the existing fields. How can I code a text box to strip out the hour/min/sec so that it does not return days into fractions?

Much mahalo's
Kevin
 
Any number of ways.

Use DateDiff with "d" for the interval.

Use CLng() for the dates.


MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top