May 17, 2010 at 7:46 am
I have a simple SP delete:
DELETE
FROM NETHistory
The table NETHistory contains a Column called "Date", the column is a "Varchar(12)".
The Date is displayed as "May 15 2010".
If I wanted to delete everything from NETHistory "where Date >= "May 16 2010"
How would I do a convert date in my SP?
Thanks
May 17, 2010 at 7:53 am
A Little Help Please (5/17/2010)
I have a simple SP delete:
DELETE
FROM NETHistory
The table NETHistory contains a Column called "Date", the column is a "Varchar(12)".
The Date is displayed as "May 15 2010".
If I wanted to delete everything from NETHistory "where Date >= "May 16 2010"
How would I do a convert date in my SP?
Thanks
First, why is a date being stored in a varchar912) column instead of a datetime column? Second, you show how the date is displayed, but is that how it is actually stored?
May 17, 2010 at 7:57 am
First, why is a date being stored in a varchar912) column instead of a datetime column? Second, you show how the date is displayed, but is that how it is actually stored?
Not sure WHY/WHO/Or what they where thinking when they designed this!!
The date is actualled stored in the DB as "May 14 2010"
May 17, 2010 at 7:58 am
A Little Help Please (5/17/2010)
First, why is a date being stored in a varchar912) column instead of a datetime column? Second, you show how the date is displayed, but is that how it is actually stored?
Not sure WHY/WHO/Or what they where thinking when they designed this!!
The date is actualled stored in the DB as "May 14 2010"
Next question, are you sure it is consistently stored in that format?
May 17, 2010 at 8:03 am
If the dates are stored consistently, check out the following. Realize that you won't be able to use any indexes on the Date column on the table because of the CONVERT function in the WHEE clause snippet.
declare @MyDate as varchar(12);
set @MyDate = 'May 16 2010';
select convert(datetime, @MyDate, 107);
where convert(datetime, @MyDate, 107) >= '20100516';
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply