Print Page | Close Window

A problem with dates

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=13295
Printed Date: 30 March 2026 at 9:21pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: A problem with dates
Posted By: zaboss
Subject: A problem with dates
Date Posted: 10 January 2005 at 3:15pm
I have discovered a strange bug in one of my applications.

The user is supposed to do some jobs, for which he has a deadline, which is the 7th of every month. After that day, he shouldn't be able to perform some actions. The code is:

If Day(Now()) > "7" then
    If Month(thefields3(2)) < Month(Now()) then
...

Well, everything worked fine, until this month, when it no longer works, because january it is not interpreted as following december... I have checked, and for february it works. So, it's only about 7th of january... Am I making any sense here? Does anybody have a clue for this?

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web



Replies:
Posted By: dj air
Date Posted: 10 January 2005 at 3:53pm

If Day(Now()) > "7" then
    If (Month(thefields3(2)) < Month(Now()) AND Month(NOW()) > 1) OR (Month(NOW()) = 1 AND Month(thefields3(2)) < 12) then


not sure if that will work. but it does in my head. it also checks if NOW = janurary and the database date < 12      12 = december

<----edit  --- >
updated statement


Posted By: ljamal
Date Posted: 10 January 2005 at 11:25pm

Dim intMonth
intMonth = Month(Date)
if intMonth = 1 then
intMonth = 13
end if

if Day(Date)>7 then
Month(thefields3(2))<intMonth then



-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming


Posted By: zaboss
Date Posted: 11 January 2005 at 2:58am
ljamal, your code will move the  problem from january to february. dj air, i'll try your suggestion.

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: zaboss
Date Posted: 11 January 2005 at 5:50am
Embarrassed Sory, ljamal,  my mistake. I missunderstood your piece of code. It works OK.

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: ljamal
Date Posted: 11 January 2005 at 10:12am
No problem, zaboss
Sometimes the simplest solution to a problem is determining what causes the problem and fixing that piece. dj air's is a great solution but for me the logic is a bit harder to follow.

-------------
L. Jamal Walton

http://www.ljamal.com/" rel="nofollow - L. Jamal Inc : Web/ Print Design and ASP Programming



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net