Crap.

Change all of the "LTE"s to "GTE"s and all of the "MOD"s to "/" (divided
by).  That'll teach me not to test code.

--
Mosh Teitelbaum
evoch, LLC
Tel: (301) 625-9191
Fax: (301) 933-3651
Email: [EMAIL PROTECTED]
WWW: http://www.evoch.com/


> -----Original Message-----
> From: Mosh Teitelbaum [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 26, 2002 6:32 PM
> To: CF-Talk
> Subject: RE: Time calculation
>
>
> DateDiff() by itself is not enough.  It can tell you the
> difference in days
> OR hours OR ..., but not all combined.  The following (untested)
> code should
> do what you want.  My apologies if it doesn't 8^).
>
> <!--- Get difference in seconds --->
> <CFSET diffSeconds = DateDiff("s", start, end)>
>
> <!--- Initialize display vars --->
> <CFSET dspDays = 0>
> <CFSET dspHours = 0>
> <CFSET dspMinutes = 0>
> <CFSET dspSeconds = 0>
>
> <!--- Get the number of days and subtract them from diffSeconds --->
> <CFSET secondsInDay = 60 * 60 * 24>
> <CFIF diffSeconds LTE secondsInDay>
>       <CFSET dspDays = diffSeconds MOD secondsInDay>
>       <CFSET diffSeconds = diffSeconds - (secondsInDay * dspDays)>
> </CFIF>
>
> <!--- Get the number of hours and subtract them from diffSeconds --->
> <CFSET secondsInHour = 60 * 60>
> <CFIF diffSeconds LTE secondsInHour>
>       <CFSET dspHours = diffSeconds MOD secondsInHour>
>       <CFSET diffSeconds = diffSeconds - (secondsInHour * dspHours)>
> </CFIF>
>
> <!--- Get the number of minutes and subtract them from diffSeconds --->
> <CFSET secondsInMinute = 60>
> <CFIF diffSeconds LTE secondsInMinute>
>       <CFSET dspMinutes = diffSeconds MOD secondsInMinute>
>       <CFSET diffSeconds = diffSeconds - (secondsInMinute * dspMinutes)>
> </CFIF>
>
> <!--- Get number of seconds --->
> <CFSET dspSeconds = diffSeconds>
>
> <!--- Display in day:hour:minute:second format --->
> <CFOUTPUT>
>       #dspDays#:#dspHours#:#dspMinutes#:#dspSeconds#
> </CFOUTPUT>
>
> --
> Mosh Teitelbaum
> evoch, LLC
> Tel: (301) 625-9191
> Fax: (301) 933-3651
> Email: [EMAIL PROTECTED]
> WWW: http://www.evoch.com/
>
>
> > -----Original Message-----
> > From: John Gedeon [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, September 26, 2002 4:45 PM
> > To: CF-Talk
> > Subject: Time calculation
> >
> >
> > I have two date and time fields, start and end. I want find the
> > difference
> > and i want to display the difference as days:hrs:mins:secs what
> > is the best
> > way to do that... ?
> >
> > Right now i use hour minute and second (built in functions) and
> > those work
> > find for differences less than one day but they do not display
> > the correct
> > amount of hours for differences longer than 1 day...
> > any suggestions
> >
> > <>< Proverbs 3:5 "Trust in the Lord with all your heart and lean not on
> > your own understanding;"
> >
> >
> 
______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to