At 01:45 PM 9/26/02, you wrote:
>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

I've been using this as a custom tag...

<cfparam name="Attributes.From" type="date">
<cfparam name="Attributes.To" type="date">
<cfparam name="Attributes.DHM" type="string">
<cfparam name="Attributes.Days" type="string">
<cfparam name="Attributes.Hours" type="string">
<cfparam name="Attributes.Mins" type="string">

<cfset diffDays = DateDiff("d", Attributes.From,Attributes.To)>
<cfset diffHours = DateDiff("h", Attributes.From,Attributes.To) - (diffDays*24)>
<cfset diffMins = DateDiff("n", Attributes.From,Attributes.To) - (diffDays*60*24) - 
(diffHours*60)>

<cfif diffHours LT 10><cfset diffHours="0#diffHours#"></cfif>
<cfif diffMins LT 10><cfset diffMins="0#diffMins#"></cfif>

<cfset "Caller.#Attributes.DHM#" = "#diffDays#:#diffHours#:#diffMins#">
<cfset "Caller.#Attributes.Days#" = diffDays>
<cfset "Caller.#Attributes.Hours#" = diffHours>
<cfset "Caller.#Attributes.Mins#" = diffMins>

______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to