about GetDate(T-SQL)

  • Thread starter Thread starter kylin
  • Start date Start date
You get a DateTime from server and you can format it on client to whatever
format you want.
You wanted to format it on client, did you?
 
Hi Kylin,

Look at cast and convert in t-sql help for numerous date formats.

HTH,

Bernie Yaeger
 
Hi,

You could use next kind of code

DECLARE @CURRENTDATE AS DATETIME SET @CURRENTDATE = GETDATE()
SELECT CONVERT(VARCHAR(4),YEAR(@CURRENTDATE)) + '-' +
REPLICATE('0',2-LEN(CONVERT(VARCHAR(2),DAY(@CURRENTDATE)))) +
CONVERT(VARCHAR(2),DAY(@CURRENTDATE)) + '-' +
REPLICATE('0',2-LEN(CONVERT(VARCHAR(2),MONTH(@CURRENTDATE)))) +
CONVERT(VARCHAR(2),MONTH(@CURRENTDATE)) + ' ' +
REPLICATE('0',2-LEN(CONVERT(VARCHAR(2),DATEPART(hh,@CURRENTDATE)))) +
CONVERT(VARCHAR(2), DATEPART(hh,@CURRENTDATE)) + ':' +
REPLICATE('0',2-LEN(CONVERT(VARCHAR(2),DATEPART(n,@CURRENTDATE)))) +
CONVERT(VARCHAR(2), DATEPART(n,@CURRENTDATE))

If you still need to keep it as a date datatype, then there is no point to
convert it in a SP, because you will see this date on a client side in a
local format, that set in a regional settings of the client's PC
 
Back
Top