• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Compare dates....

New Here ,
Jun 07, 2006 Jun 07, 2006

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

264

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 07, 2006 Jun 07, 2006

Copy link to clipboard

Copied

If qTest.LastRegisteredTime is this:
20060507072033Z

You can do this
<cfset myDate = CreateDate(left(qTest.LastRegisteredTime, 4),
mid(qTest.LastRegisteredTime, 5, 2),
mid(qTest.LastRegisteredTime, 7, 2)>

For this part:
And if the date has another (earlyer) year or a month value of two months earlier then the current month (in the same year)..

Do this
<cfif datediff("yyyy", mydate, now()) gte 1
or
( datediff("m", mydate, now()) gte 2
and year(mydate) is year(now())
>
do something

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 08, 2006 Jun 08, 2006

Copy link to clipboard

Copied

LATEST
Well Thank you very much!

This actually is a lot more siple then I expected...

Regards,
Kabbi

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation