Panos
asked on
datediff in cfml
Hello experts.
I want to use the datediff function i had using mssql now with mysql but i can't get it work.
Any help?
<cfquery name="gettime" datasource="#request.dsn#" >
SELECT requestpw,user_ID
From users
Where uuidpw = <cfqueryparam cfsqltype="cf_sql_varchar" value="#url.resetpw#">
</cfquery>
<cfif gettime.recordcount NEQ 0>
<cfscript>
date1 = #LSParseDateTime(gettime.r equestpw)# ;
date2 = now();
REQUESTEXITS = 1;
</cfscript>
<cfif dateDiff("h",date1, Date2) lt 24 >
<cfset oldrequest = 1 />
<cfelse>
<cfset oldrequest = 0 />
</cfif>
I want to use the datediff function i had using mssql now with mysql but i can't get it work.
Any help?
<cfquery name="gettime" datasource="#request.dsn#"
SELECT requestpw,user_ID
From users
Where uuidpw = <cfqueryparam cfsqltype="cf_sql_varchar"
</cfquery>
<cfif gettime.recordcount NEQ 0>
<cfscript>
date1 = #LSParseDateTime(gettime.r
date2 = now();
REQUESTEXITS = 1;
</cfscript>
<cfif dateDiff("h",date1, Date2) lt 24 >
<cfset oldrequest = 1 />
<cfelse>
<cfset oldrequest = 0 />
</cfif>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi.
agx. You are right.It is cf code but for the following test code i get output 0.
<cfset set = '0879E1C5-DF40-8B46-5E7036 434BBF14C2 '>
<cfquery name="gettime" datasource="#request.dsn#" >
SELECT requestpw,user_ID
From users
Where uuidpw = <cfqueryparam cfsqltype="cf_sql_varchar" value="#set#">
</cfquery>
<cfif gettime.recordcount NEQ 0>
<cfscript>
date1 = #LSParseDateTime(gettime.r equestpw)# ;
date2 = now();
REQUESTEXITS = 1;
</cfscript>
<cfif dateDiff("h",date1, Date2) lt 24 >
<cfset oldrequest = 1 />
<cfelse>
<cfset oldrequest = 0 />
</cfif>
</cfif>
<cfset dif = dateDiff("h",Date2, date1)>
<cfoutput>#dif#</cfoutput>
( requestpw value in db = 2010-09-22 16:59:23)
agx. You are right.It is cf code but for the following test code i get output 0.
<cfset set = '0879E1C5-DF40-8B46-5E7036
<cfquery name="gettime" datasource="#request.dsn#"
SELECT requestpw,user_ID
From users
Where uuidpw = <cfqueryparam cfsqltype="cf_sql_varchar"
</cfquery>
<cfif gettime.recordcount NEQ 0>
<cfscript>
date1 = #LSParseDateTime(gettime.r
date2 = now();
REQUESTEXITS = 1;
</cfscript>
<cfif dateDiff("h",date1, Date2) lt 24 >
<cfset oldrequest = 1 />
<cfelse>
<cfset oldrequest = 0 />
</cfif>
</cfif>
<cfset dif = dateDiff("h",Date2, date1)>
<cfoutput>#dif#</cfoutput>
( requestpw value in db = 2010-09-22 16:59:23)
ASKER
Hi gigipaul
24 hours are 1 day.That's it what i need.The problem is somewhere else.
24 hours are 1 day.That's it what i need.The problem is somewhere else.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi.
I don't know what the problem wasbut it is working now with and without LSParseDateTime().
Thank you both.
I don't know what the problem wasbut it is working now with and without LSParseDateTime().
Thank you both.
ASKER
Thank you both for your help.I gave some points to expert gigipaul for his interest in my question.It was my mistace to include the mysql zone.
regards
panos
regards
panos
The code posted isn't using database functions, it's using CF's DateDiff() function. Can you explain what's not working... rre you getting an error message?