November 4, 2009 at 5:17 am
Hi All,
I have a table which contains a number of columns all set as NVARCHAR(50).
One column in particular i want to query is a column called "Date" (lol)
Example date in column "Date" :
08/11/1999
26/11/1999
26/11/1999
Unfortunately the column is set to NVARCHAR(50) so I cannot do:
Select *
FROM Client
WHERE date >= '08/11/1999'
I have tried things like:
select cast('bgn date' as datetime)
from dbo.Client
Does not work
How can I resolve this?
November 4, 2009 at 5:44 am
CONVERT( datetime, [Date], 103 )
November 4, 2009 at 8:12 am
OK, thanks.
I used the following:
SELECT CONVERT( datetime, [bgn date], 103 ) as date
from date
Two things
1. I want to select the rest of the columns in the table too.
2. I need to add a where clause where date >= 08/11/1999
November 4, 2009 at 9:40 am
Prehaps this will help
CREATE TABLE #Client(ClientID INT,[bgn Date] VARCHAR(50))
INSERT INTO #Client
SELECT 1,'08/11/1999' UNION ALL
SELECT 2, '26/11/1999' UNION ALL
SELECT 3, '26/11/1999'
SELECT Clientid,CONVERT( datetime, [bgn date], 103 ) as date from #Client
WHERE CONVERT( datetime, [bgn date], 103 ) > CONVERT( datetime, '08/11/1999', 103 )
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply