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

DateDiff conversion question.

Status
Not open for further replies.

programmher

Programmer
May 25, 2000
235
US
I have two dates that I need to find the difference. I am using the following:

<cfset ProcessTime = DateDiff(&quot;d&quot;,DateEntered,DateShipped)

I get the following result:

Date entered:20010712 Date Shipped: 20010828
ProcessTime: 116

I need to convert the ProcessTime so it is 47 instead of 116.

What is the proper way to do this?
 
You need to enter the date into ColdFusion in a date format that CF recognises (using slashes,dashes or long date formats), so that Cold Fusion can treat these as dates.

The safest way to do this is by using the CeateDate function.
<cfset DateEntered = CreateDate(2001,7,12)>
<cfset DateShipped = CreateDate(2001,8,28)>
<cfset ProcessTime = DateDiff(&quot;d&quot;,DateEntered,DateShipped)>

This should give you what you want.
 
jackied-

Thanks for the suggestion! When I tried this, I got an actual date (like this: 19964029) instead of a number (which is what I needed).

I need to reflect how many days have lapsed between 20010901 and 20010912 (just using this as an example).
 
Please try it again. I tested it and it works fine. Here is the code that I tested:
Code:
<cfset DateEntered = CreateDate(2001,7,12)>
<cfset DateShipped = CreateDate(2001,8,28)>
<cfset ProcessTime = DateDiff(&quot;d&quot;,DateEntered,DateShipped)>
<cfoutput>
#processtime#
</cfoutput>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top