|
Posted by fjleon on 10/02/50 11:48
> Try:
>
> SELECT myday, mymonth, myyear,
> DATEADD(DAY,myday,
> DATEADD(MONTH,mymonth,
> DATEADD(YEAR,myyear-2000,'19991231')))
> FROM mytable ;
>
> This returns a DATETIME, not a string.
Seems to be one month forward:
SELECT myday, mymonth, myyear
DATEADD(DAY,myday,DATEADD(MONTH,mymonth,
DATEADD(YEAR,myear-2000,'19991231') ) )
FROM mytable
10 5 2006 2006-06-10 00:00:00.000
20 5 2006 2006-06-20 00:00:00.000
I had to substract a month:
SELECT myday, mymonth, myyear
DATEADD(DAY,myday,DATEADD(MONTH,mymonth-1,
DATEADD(YEAR,myear-2000,'19991231') ) )
FROM mytable
I am guessing this only works from y2k forward. I don't quite
understand why i have to substract a month, but at least it works, and
it's a lot cleaner than casting around.
Navigation:
[Reply to this message]
|