Re: Update 'Date': Set Day(Date) to a Certain Number
- From: Hugo Kornelis <hugo@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 05 Jan 2006 20:30:42 +0100
On Wed, 4 Jan 2006 05:31:07 -0800, PML wrote:
>Hi,
>
>I am trying to use an update command to set the day of a date to a certain
>number. For example, if the date is 1/4/06, I might want to set day(date) to
>'7'. So it turns into 1/7/06. I wasn't sure if there was a way to do this
>and I keep getting errors when I try it.
Hi PML,
And here's a third way: convert existing date to YYYYMM, add string
representation of wanted day to arrive at YYYYMMDD, convert back to
date:
SELECT CAST(CONVERT(char(6), @datetime, 112)
+ RIGHT('0' + CAST(@newDay AS varchar(2)), 2) AS datetime)
Best, Hugo
--
Angband spoilers: http://ourworld.compuserve.com/homepages/hugo_kornelis/Angband/Spoiler/index.htm
Angband UI Patch: http://ourworld.compuserve.com/homepages/hugo_kornelis/Angband/UIpatch/index.htm
--
.
- Prev by Date: Re: How to select all top 1s from different group in a view
- Next by Date: Re: How to select all top 1s from different group in a view
- Previous by thread: Re: Update 'Date': Set Day(Date) to a Certain Number
- Next by thread: Re: How to select all top 1s from different group in a view
- Index(es):