Friday, February 24, 2012

Datepart curiosity.

Help,
I have build a Bip portal (Analysertool) wich gets information out of sql
server. I have a date field over there.
When the Analiser tools detects a date field it construkts 2 new fields...
field bij year and field by w. BUT this are the our w nummers + 1. So
the w numbers are not correct. I tried making a vieuw in SQL server. But
the function Datepart() gives me the same w number! Does anyone know a
solution'
Tnx in advanceDatepart doesn't calculate w numbers according to the ISO standard. Searc
h Books Online for the
ISOW function instead.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Judith van der Niet" <jniet@.mit.com> wrote in message
news:eW%235ZsrLFHA.568@.TK2MSFTNGP09.phx.gbl...
> Help,
> I have build a Bip portal (Analysertool) wich gets information out of sql
server. I have a date
> field over there.
> When the Analiser tools detects a date field it construkts 2 new fields...
. field bij year and
> field by w. BUT this are the our w nummers + 1. So the w numbers
are not correct. I tried
> making a vieuw in SQL server. But the function Datepart() gives me the sam
e w number! Does
> anyone know a solution'
> Tnx in advance
>|||You can use "SET DATEFIRST" to set the first day of the w to your
desired day.
If you want monday to be the first day then use
SET DATEFIRST 1
If you want tuesday to be the first then
SET DATEFIRST 2 .
and so on ...
Bala|||SET DATEFIRST Can be used for setting the startt day of the w.|||Note that DATEPART still won't return ISO w numbers if DATEFIRST is
set to 1. For that you should use the ISOWEEK function given in Books
Online as Tibor suggested.
David Portas
SQL Server MVP
--

No comments:

Post a Comment