gadjodilo77
Programmer
Hi,
I have a question. I have to get information out of a Novell database using LDAP. One thing is the "LastRegisteredTime" all that is possibble and it give the dat like this:
20060507072033Z To us e this date I had to rearrange it a little bit...
So it ends up like this:
2006-05-07.
What I really want to do is to compare this date with the current date... And if the date has another (earlyer) year or a month value of two months earlier then the current month (in the same year)... Then I would like to show the data for these records...
Currently I made something like this:
However it still doesn't do what I want:
<cfset jaar1 = DateFormat(Now(), "YYYY-MM-DD")>
<cfldap action="QUERY"
name="qtest"
attributes="cn, wMNAMEUser, zENINVSerialNumber, ZENINVlastscandate, wMLastRegisteredTime, lastLoginTime"
start=""
scope="SUBTREE"
filter="objectClass=Workstation"
server=""
>
<!--- last registered date bewerken--->
<cfset jaar= left(qtest.wMLastRegisteredTime, 4)>
<cfset maand= Mid(qtest.wMLastRegisteredTime,5,2)>
<cfset dag= Mid(qtest.wMLastRegisteredTime,7,2)>
<cfset datum = #DateFormat(CreateDate(jaar, maand, dag), "yyyy-mm-dd")#>
<cfloop query="qtest">
<cfset jaar= left(qtest.wMLastRegisteredTime, 4)>
<cfset maand= Mid(qtest.wMLastRegisteredTime,5,2)>
<cfset dag= Mid(qtest.wMLastRegisteredTime,7,2)>
<cfset datum = #DateFormat(CreateDate(jaar, maand, dag), "yyyy-mm-dd")#>
<cfset comparison = DateCompare(datum, jaar1)>
<cfswitch expression = #comparison#>
<cfcase value = "-1">
<h3><cfoutput>#DateFormat(datum)#
</cfoutput> (Date 1) is
earlier than <cfoutput>#DateFormat(jaar1)#
</cfoutput> (Date 2)</h3>
<I>The dates are not equal</I>
</cfcase>
<cfcase value = "0">
<h3><cfoutput>#DateFormat(datum)#
</cfoutput> (Date 1) is equal
to <cfoutput>#DateFormat(jaar1)#
</cfoutput> (Date 2)</h3>
<I>The dates are equal!</I>
</cfcase>
<cfcase value = "1">
<h3><cfoutput>#DateFormat(datum)#
</cfoutput> (Date 1) is later
than <cfoutput>#DateFormat(jaar1)#
</cfoutput> (Date 2)</h3>
<I>The dates are not equal</I>
</cfcase>
<CFDEFAULTCASE>
<h3>This is the default case</h3>
</CFDEFAULTCASE>
</cfswitch>
</loop>
Is there somebody who could help me? The yyy-mm-dd notation is usable in MySQL, but it is not a Coldfusion date I believe?? (maybe?). Could that also be a problem?
Hopefully somebody understands what I mean.
Thank you in advance.
Regards,
Kabbi
I have a question. I have to get information out of a Novell database using LDAP. One thing is the "LastRegisteredTime" all that is possibble and it give the dat like this:
20060507072033Z To us e this date I had to rearrange it a little bit...
So it ends up like this:
2006-05-07.
What I really want to do is to compare this date with the current date... And if the date has another (earlyer) year or a month value of two months earlier then the current month (in the same year)... Then I would like to show the data for these records...
Currently I made something like this:
However it still doesn't do what I want:
<cfset jaar1 = DateFormat(Now(), "YYYY-MM-DD")>
<cfldap action="QUERY"
name="qtest"
attributes="cn, wMNAMEUser, zENINVSerialNumber, ZENINVlastscandate, wMLastRegisteredTime, lastLoginTime"
start=""
scope="SUBTREE"
filter="objectClass=Workstation"
server=""
>
<!--- last registered date bewerken--->
<cfset jaar= left(qtest.wMLastRegisteredTime, 4)>
<cfset maand= Mid(qtest.wMLastRegisteredTime,5,2)>
<cfset dag= Mid(qtest.wMLastRegisteredTime,7,2)>
<cfset datum = #DateFormat(CreateDate(jaar, maand, dag), "yyyy-mm-dd")#>
<cfloop query="qtest">
<cfset jaar= left(qtest.wMLastRegisteredTime, 4)>
<cfset maand= Mid(qtest.wMLastRegisteredTime,5,2)>
<cfset dag= Mid(qtest.wMLastRegisteredTime,7,2)>
<cfset datum = #DateFormat(CreateDate(jaar, maand, dag), "yyyy-mm-dd")#>
<cfset comparison = DateCompare(datum, jaar1)>
<cfswitch expression = #comparison#>
<cfcase value = "-1">
<h3><cfoutput>#DateFormat(datum)#
</cfoutput> (Date 1) is
earlier than <cfoutput>#DateFormat(jaar1)#
</cfoutput> (Date 2)</h3>
<I>The dates are not equal</I>
</cfcase>
<cfcase value = "0">
<h3><cfoutput>#DateFormat(datum)#
</cfoutput> (Date 1) is equal
to <cfoutput>#DateFormat(jaar1)#
</cfoutput> (Date 2)</h3>
<I>The dates are equal!</I>
</cfcase>
<cfcase value = "1">
<h3><cfoutput>#DateFormat(datum)#
</cfoutput> (Date 1) is later
than <cfoutput>#DateFormat(jaar1)#
</cfoutput> (Date 2)</h3>
<I>The dates are not equal</I>
</cfcase>
<CFDEFAULTCASE>
<h3>This is the default case</h3>
</CFDEFAULTCASE>
</cfswitch>
</loop>
Is there somebody who could help me? The yyy-mm-dd notation is usable in MySQL, but it is not a Coldfusion date I believe?? (maybe?). Could that also be a problem?
Hopefully somebody understands what I mean.
Thank you in advance.
Regards,
Kabbi