Re: Update 'Date': Set Day(Date) to a Certain Number



"PML" <PML@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AA252BD5-DD93-4810-954D-FED5820E7B21@xxxxxxxxxxxxxxxx
> 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.
>
> Thanks,

For example:

UPDATE tbl
SET dt = DATEADD(DAY,7-DAY(dt),dt)
WHERE ... ;

Where 7 is the date you want to set.

--
David Portas
SQL Server MVP
--


.



Relevant Pages

  • Re: Why does this code not generate an error?
    ... >> Why don't you just try it with a complete update command (nothing ... from what you are sure that it is incorrect and sees what it ... Cor ... Prev by Date: ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Update only few columns DATAGRID
    ... > This way the update command will not need this paramater. ... >> OnUpdateCommand event? ... Prev by Date: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: help with update table
    ... but it is posible, just use UPDATE command? ... Prev by Date: ...
    (comp.databases.ms-access)
  • Re: What is wrong with my query
    ... >I need to update my table with a update command and a select command. ... >sure it will work in SQL but how do I manage this in access ... UPDATE tblDemeUsers INNER JOIN tblser2 ... Prev by Date: ...
    (microsoft.public.access.queries)
  • What is wrong with my query
    ... I need to update my table with a update command and a select command. ... sure it will work in SQL but how do I manage this in access ... Prev by Date: ...
    (microsoft.public.access.queries)