I want to retrieve a date time field from SQL server. The format I want it to be retrieved is:
YYYY/MM/DD-hh:mm:ss:lll (l = millisec)
example '2006/06/21-15:26:39:994'.
Can somebody please tell me how to do it. I know how to do it in Oracle, but not in SQL server.

date time format
ArtemB
SELECT CONVERT(NVARCHAR(10), getdate(), 111) + '-' + RIGHT(CONVERT(NVARCHAR(23), getdate(), 21),12)
Or
SELECT REPLACE(REPLACE(CONVERT(NVARCHAR(23), getdate(), 127),'-', '/'), 'T','-')
san7
theirs is better
A_Martin
Gaurav Khera
Frank Hileman
declare @test datetime
set @test = getdate()
select convert(varchar(100),@test,121)
select convert(varchar(100),@test,120)
select convert(varchar(100),@test,126)
the third parameter is key here, which is the STYLE argument.