Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.basic.visual.misc > #353
| From | Dr J R Stockton <reply1128@merlyn.demon.co.uk> |
|---|---|
| Newsgroups | comp.lang.basic.visual.misc |
| Subject | Re: Possible Date Bug |
| Date | 2011-07-17 19:32 +0100 |
| Organization | Home |
| Message-ID | <631XCLIFryIOFwHh@invalid.uk.co.demon.merlyn.invalid> (permalink) |
| References | <KL+b9hCUxcHOFwaT@invalid.uk.co.demon.merlyn.invalid> <ivljkd$bqi$1@speranza.aioe.org> <hcJhIUE03KIOFwHE@invalid.uk.co.demon.merlyn.invalid> <ivrfpf$msr$1@speranza.aioe.org> |
In comp.lang.basic.visual.misc message <ivrfpf$msr$1@speranza.aioe.org>, Sat, 16 Jul 2011 03:48:46, Nobody <nobody@nobody.com> posted: >"Dr J R Stockton" <reply1128@merlyn.demon.co.uk> wrote in message >news:hcJhIUE03KIOFwHE@invalid.uk.co.demon.merlyn.invalid... >> In 2003, as you may recall, December 29th was a Monday. The nearest >> Thursday was January 1st 2004, and the ISO 8601 week number was >> therefore 1, written "01". >> >> Perhaps you are not familiar with ISO 8601? >> >> There are errors for 2003-12-29, 2007-12-31, and 2019-12-30, in >> IE4, IE6, IE7 & IE8 - intervals 4, 12, 12 years recurring, >> except across missing Leap Years (I did not test IE5). There is a >> different error for 2101-01-02, +/- any multiple of 400 years. >> >> You did not say what version of VB gave what result. > >You are right. Searching for "DatePart bug" in MSKB shows this article: Naturally. But one should never consider Microsoft to be authoritative on anything other than their own products, especially anything not commonly used in the USA. >BUG: Format or DatePart Functions Can Return Wrong Week Number for Last >Monday in Year >http://support.microsoft.com/kb/200299 They have been told to read <http://www.merlyn.demon.co.uk/vb-date2.htm> which has a much more sensible, faster, shorter algorithm. It uses the "understand and code" method rather than the "guess, try, patch" one. Of course (for those who understand ISO 8601 week numbering), the Year Number also needs to be found (and the Day Number might be useful), This code is Web-page VBScript from cited vb-date2.htm; I suppose it can easily be made to run in Visual Basic, Sub WeekNumJRS(Tdy, YNo, WNo, DoW) '' Tdy is CDate in; Y W D out Dim N, Thu, SoY '' ISO 8601 Y>=1900 ( because of \ & mod ) DoW = ((Tdy+5) mod 7) + 1 N = 2 Thu = ((Tdy+3+N) \ 7) * 7 - N '' Nearest Thu YNo = Year(Thu) SoY = DateSerial(YNo, 1, 1) '' Date, YYYY-01-01 WNo = ((Thu - SoY) \ 7) + 1 end Sub Years before 1900 can be handled by adding a sufficient multiple of 400 to the year. >VB6+SP5 on XP Pro+SP2 returns 53 for the code line that you posted in the >OP. I'm on XP Pro SP3. I've added that result to my cited page. Thanks. -- (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05. Website <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.
Back to comp.lang.basic.visual.misc | Previous | Next — Previous in thread | Find similar
Possible Date Bug Dr J R Stockton <reply1128@merlyn.demon.co.uk> - 2011-07-13 17:48 +0100
Re: Possible Date Bug "Nobody" <nobody@nobody.com> - 2011-07-13 22:17 -0400
Re: Possible Date Bug Dr J R Stockton <reply1128@merlyn.demon.co.uk> - 2011-07-15 22:15 +0100
Re: Possible Date Bug "Henning" <computer_hero@coldmail.com> - 2011-07-16 01:35 +0200
Re: Possible Date Bug "Henning" <computer_hero@coldmail.com> - 2011-07-16 01:40 +0200
Re: Possible Date Bug Dr J R Stockton <reply1128@merlyn.demon.co.uk> - 2011-07-17 18:39 +0100
Re: Possible Date Bug "Nobody" <nobody@nobody.com> - 2011-07-16 03:48 -0400
Re: Possible Date Bug Dr J R Stockton <reply1128@merlyn.demon.co.uk> - 2011-07-17 19:32 +0100
csiph-web