Why is the week number returned by SQL Server wrong? - 29 Nov 1999

A. e.g. select datepart(wk,'19990323') returns 13 when it should be 12.

This is because SQL Server starts counting weeks from Jan 1. Week 1 = Jan 1.

The ISO standard is that week 1 is the first week with 4 days in it.

You will have to write your own bit of SQL to calculate it...


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish