August 5, 2008 at 8:18 am
I need to remove all rows from a table based on the date value being at lease sixty days old from the update date (i.e. today). The syntax needs to be part of a table update job.
What's the syntax to tell it to remove x number of rows. Does it start with 'Update Table' or 'Alter Table Alter column', etc.
I'm not really sure.
thx,
John
August 5, 2008 at 8:38 am
latingntlman (8/5/2008)
I need to remove all rows from a table based on the date value being at lease sixty days old from the update date (i.e. today). The syntax needs to be part of a table update job.What's the syntax to tell it to remove x number of rows. Does it start with 'Update Table' or 'Alter Table Alter column', etc.
I'm not really sure.
thx,
John
It starts with delete.
something like:
delete from mytable where datatimeColumnThatHasTheDateofUpdate< dateadd(day, -60, getdate())
Regards,
Andras
August 5, 2008 at 12:15 pm
thx,
Now I need to convert getdate() as 2008-08-06 00:00:00
What's the best syntax I can use?
JOhn
August 6, 2008 at 1:49 am
latingntlman (8/5/2008)
thx,Now I need to convert getdate() as 2008-08-06 00:00:00
What's the best syntax I can use?
JOhn
If you want a datetime then:
select DATEADD(Day, 0, DATEDIFF(Day, 0, getdate()))
if you want a varchar without the milliseconds then:
select convert(varchar(40), DATEADD(Day, 0, DATEDIFF(Day, 0, getdate())), 20)
Regards,
Andras
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply