nmarano
asked on
dateDiff
Experts-
I'm trying to get the difference in minutes between a date that is stored like this...
2011-06-13 08:11:45.000
and now()
Any help would be appreciated.
Thanks
I'm trying to get the difference in minutes between a date that is stored like this...
2011-06-13 08:11:45.000
and now()
Any help would be appreciated.
Thanks
ASKER
This is being pulled from a database.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Sid-
Just got it, so I have
<cfset newdate = #CreateODBCDateTime("2011- 06-13 08:11:45.000")#>
<cfset today = #CREATEODBCDATETIME(now()) #>
<cfdump var="#newDate#"><br>
<cfdump var="#today#">
<cfset newerdate = #DATEDIFF("n", today,newdate)#>
<cfif newerdate GTE 5>
<cfoutput>
This is not a dup
</cfoutput>
<cfelse>
Do you really want to be double charged?
</cfif>
Just got it, so I have
<cfset newdate = #CreateODBCDateTime("2011-
<cfset today = #CREATEODBCDATETIME(now())
<cfdump var="#newDate#"><br>
<cfdump var="#today#">
<cfset newerdate = #DATEDIFF("n", today,newdate)#>
<cfif newerdate GTE 5>
<cfoutput>
This is not a dup
</cfoutput>
<cfelse>
Do you really want to be double charged?
</cfif>
"Do you really want to be double charged?"
haha that's great
Why yes, Yes I do.
haha that's great
Why yes, Yes I do.
>> <cfset newdate = #CreateODBCDateTime("2011- 06-13 08:11:45.000")#>
>> <cfset today = #CREATEODBCDATETIME(now()) #>
As long as you're using a date/time column, you don't need the create...() functions. The query value will be a date object already. So is now(). The extra functions won't break anything, working, but all you really need is:
<cfif DATEDIFF("n", today,newdate) GTE 5>...<cfelse>....</cfif>
>> <cfset today = #CREATEODBCDATETIME(now())
As long as you're using a date/time column, you don't need the create...() functions. The query value will be a date object already. So is now(). The extra functions won't break anything, working, but all you really need is:
<cfif DATEDIFF("n", today,newdate) GTE 5>...<cfelse>....</cfif>
ie <cfif DATEDIFF("n", now(), youQuery.dateColumn) GTE 5>...<cfelse>....</cfif>
=ROUND((NOW()-A1)*1440,0)
Assumes that A1 is in the past - gives you the time difference to the nearest minute
regards, barry