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

Week Function gives wrong week of year.

Guest
Jul 20, 2010 Jul 20, 2010

Hi all,

I just figured out the week function is adding a week to the actual week of year.

A date of 2010-07-21 returns a week of 30 not 29. And ideas??

This a Windows 2003 server running Coldfusion MX 7

Many thanks for the help.

Brian

1.6K
Translate
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
Participant ,
Jul 21, 2010 Jul 21, 2010

Why is 30 incorrect? Jan 1, 2010 is included in week 1. You count from there till July 21, 2010 and you'll get week 30.

Translate
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 ,
Jul 21, 2010 Jul 21, 2010

It might be time to upgrade CF.  I just ran a test on CF8, and both week() and datePart() return 29 for the week number for 21/7/2010.

--

Adam

Translate
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 ,
Jul 21, 2010 Jul 21, 2010

So, January 1 was a Friday, right?  Here's what my data warehouse thinks about that.

select datepart(week, '20100102') from u_one; -- Saturday

          1
select datepart(week, '20100103') from u_one;  -- Sunday

          2

select datepart(week, current_date) from u_one;

         30

Translate
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 ,
Jul 21, 2010 Jul 21, 2010

Dan Bracuk wrote:

So, January 1 was a Friday, right?  Here's what my data warehouse thinks about that.

select datepart(week, '20100102') from u_one; -- Saturday

          1
select datepart(week, '20100103') from u_one;  -- Sunday

          2

select datepart(week, current_date) from u_one;

         30

A system conforming to ISO 8601 would disagree there.  Firstly, weeks start on a Mon as far as these things go (obviously human calendars vary by country, standards-adhering ones do not), so both of those should be the same week.

Also, Week 1 is the week that has the first Thursday of the year in it, so Week 1 doesn't start until the Monday after your test dates.  Those dates are in week 53 from the previous year.

CF (well: CF8, anyhow) seems to conform to ISO 8601.  CFMX7... seemingly not so much.

Ref: http://en.wikipedia.org/wiki/ISO_week_date

--
Adam

Translate
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
Guest
Jul 21, 2010 Jul 21, 2010

OK so Im probably not doing anything wrong then?? Maybe? So if this is an issue with MX7 you would think there would be a fix for it. Where does CF calculate this information from? The OS, JRE? I think I would find more people that had run into this issue. Makes me think I have something wrong or misconfigured. I hate work arounds but can anyone offer any suggestions?

Thanks all for the help.

Brian

Translate
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 ,
Jul 21, 2010 Jul 21, 2010
LATEST

Java does almost all the work. Maybe upgrade your JVM? note: Verity - if you use it - might have issues with the latest JVMs, but CFMX itself should be fine (test first!).

I would not expect any further hotfixes or updates for CFMX7 as it's:

A) five years old;

B) into "extended support";

C) two versions behind the current state of play.

What your expectation should be here is that it's perhaps about time to upgrade

--

Adam

Translate
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