Link to home
Start Free TrialLog in
Avatar of nmarano
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
Avatar of barry houdini
barry houdini
Flag of United Kingdom of Great Britain and Northern Ireland image

If you have that value in cell A1 try this formula in B1

=ROUND((NOW()-A1)*1440,0)

Assumes that A1 is in the past - gives you the time difference to the nearest minute

regards, barry
Avatar of nmarano
nmarano

ASKER

This is being pulled from a database.
ASKER CERTIFIED SOLUTION
Avatar of SidFishes
SidFishes
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nmarano

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>
"Do you really want to be double charged?"

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>


ie <cfif DATEDIFF("n", now(), youQuery.dateColumn) GTE 5>...<cfelse>....</cfif>