Date Problem

# Thread: Date Problem

1. Senior Member
Join Date
Dec 1969
Posts
144

## Date Problem

I am trying to do a dateadd but do not seem to be doing it correctly. I want to have the dates the are at 90 days (3 months) from today return "90 days", 60 days (2 months) return "60 days", 30 days (1 month) return "30 days" and if past todays date, return "Expired". Right now, all I am getting is "Expired" no matter when the date is. I am missing something in my code:<BR><BR><BR><BR>ExpDate = objRec("ClassExpireDate")<BR><BR>if ExpDate = (Dateadd("m", 3, expDate)) then<BR>strExpStatus = "90 days"<BR>elseif ExpDate = (Dateadd("m", 2, expDate)) then<BR>strExpStatus = "60 days"<BR>elseif ExpDate = (Dateadd("m", 1, expDate)) then<BR>strExpStatus = "30 days"<BR>else<BR>strExpStatus = "Expired"<BR>end if<BR><BR><BR>Any help would be appreciated. Thanks.

2. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: Date Problem

DateDiff More suited to your needs<BR><BR>if DateDiff(date(), objRec("ClassExpireDate")) &#060;= 0 Then<BR><BR> strExpStatus = "Expired"<BR>Else<BR> strExpStatus = (30 * DateDiff(date(), objRec("ClassExpireDate"))) & " Days"<BR><BR>End if

3. Senior Member
Join Date
Dec 1969
Posts
144

## Type Mismatch?

I am getting a Type Mismatch error on the first line??<BR><BR>if DateDiff(date(), objRec("ClassExpireDate")) &#060;= 0 Then<BR><BR>??

4. Senior Member
Join Date
Dec 1969
Posts
11,247

## My bad

if DateDiff("m", date(), objRec("ClassExpireDate")) &#060;= 0 Then

5. Senior Member
Join Date
Dec 1969
Posts
144

## Only One Result

That cleared the Type mismatch up. Now I am only getting "Expired" even with dates that are 90/60/30 days away?<BR><BR>if DateDiff("m", Now(), objRec("ClassExpireDate")) &#060;= 0 Then<BR><BR> strExpStatus = "Expired"<BR>Else<BR>strExpStatus = (30 * DateDiff(date(), objRec("ClassExpireDate"))) & " Days"<BR><BR>End if<BR><BR>Thanks.

6. Senior Member
Join Date
Dec 1969
Posts
11,247

## RE: Only One Result

[code language="VBScript"]<BR>&#060;%<BR>if DateDiff("m", date(), objRec("ClassExpireDate")) &#060;= 0 Then<BR><BR> strExpStatus = "Expired"<BR>Else<BR>strExpStatus = (30 * DateDiff("m", date(), objRec("ClassExpireDate"))) & " Days"<BR><BR>End if%&#062;<BR> &#060;%=strExpStatus %&#062;<BR>[/code]

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•