TRY THIS
SELECT CONVERT(VARCHAR(10), '2006-06-03 23:00:00')
REGARDS
ANAS
|||This only works if the field is a varchar. You would need to set a different style or you will get "Jun 3 200". See below...
IF OBJECT_ID('test', 'U') IS NOT NULL
DROP TABLE dbo.test
GO
CREATE TABLE dbo.test
(
testDate datetime
)
INSERT dbo.test (testDate) VALUES ('2006-06-03 23:00:00')
--This returns "Jun 3 200"
SELECT CONVERT(VARCHAR(10), testDate) FROM dbo.test
--This returns 2006-06-03
SELECT REPLACE(CONVERT(VARCHAR(10), testDate, 102), '.', '-') FROM dbo.test
No comments:
Post a Comment