Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - A problem with dates
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

A problem with dates

 Post Reply Post Reply
Author
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Topic: A problem with dates
    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
Soft 4 web
Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Post Options Post Options   Thanks (0) Thanks(0)   Quote dj air Quote  Post ReplyReply Direct Link To This Post 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


Edited by dj air - 10 January 2005 at 3:54pm
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post 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
Soft 4 web
Back to Top
zaboss View Drop Down
Senior Member
Senior Member


Joined: 20 August 2002
Location: Romania
Status: Offline
Points: 454
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaboss Quote  Post ReplyReply Direct Link To This Post Posted: 11 January 2005 at 5:50am
Embarrassed Sory, ljamal,  my mistake. I missunderstood your piece of code. It works OK.
Cristian Banu
Soft 4 web
Back to Top
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.