| Author |
Topic  |
|
|
theKid27
Starting Member
16 Posts |
Posted - 03/13/2013 : 22:24:12
|
Hi Experts/Members,
I have a table - [Removed] which data as below:
DltDate Jan-11 Feb-11 Mar-13
I want to delete the data when the condition is not meet as below:
Delete from Removed where [DltDate] <=DateAdd(Year,-1,getdate())
but it gives me errors. Conversion failed when converting date and/or time from character string.
Then i tried to convert the getdate to this format e.g.[Feb-2013]
SELECT REPLACE(RIGHT(CONVERT(VARCHAR(11), GETDATE(), 106), 8), ' ', '-')
DELETE FROM Removed WHERE [DltDate] <= DATEADD(year,-1,(SELECT REPLACE(RIGHT(CONVERT(VARCHAR(11), GETDATE(), 106), 8), ' ', '-')) )
But when i combine it it still give me this error Conversion failed when converting date and/or time from character string.
Kindly hope that you all can provide some advice on this.
Thank you.
|
|
|
bandi
Flowing Fount of Yak Knowledge
India
1430 Posts |
Posted - 03/14/2013 : 03:25:37
|
DELETE FROM Removed WHERE convert(datetime,'01-' + DltDate,120) <= DATEADD( Year, -1, getdate())
-- Chandu |
 |
|
|
theKid27
Starting Member
16 Posts |
Posted - 03/14/2013 : 05:20:58
|
| thanks bandi |
 |
|
|
bandi
Flowing Fount of Yak Knowledge
India
1430 Posts |
Posted - 03/14/2013 : 06:00:21
|
quote: Originally posted by theKid27
thanks bandi
Welcome
-- Chandu |
 |
|
| |
Topic  |
|
|
|