0

NEED an output like

11/23/15 05:14:05 PM
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
George
  • 61
  • 7
  • 1
    Possible duplicate of [SQL SERVER DATETIME FORMAT](http://stackoverflow.com/questions/14769547/sql-server-datetime-format) – Kumar Saurabh Nov 24 '15 at 10:11

2 Answers2

2

Try this..

SELECT CONVERT(VARCHAR(20), SYSDATETIME(), 22)

there are many available formats on the net.. try some googling.

below are sample link:

http://www.sql-server-helper.com/sql-server-2008/sql-server-2008-date-format.aspx

japzdivino
  • 1,736
  • 3
  • 17
  • 25
1

Or you can try this:

SELECT FORMAT(GETDATE(), 'MM/dd/yy hh:mm:ss tt', 'en-US') 

You can customize the date time format as you like.

Harlo
  • 507
  • 2
  • 12
  • 2
    Works only in SQL Server **2012** and newer since `FORMAT` was introduced in the 2012 version - isn't available in earlier versions (and the OP says he's using SQL Server **2008 R2** which doesn't have `FORMAT` yet) – marc_s Nov 24 '15 at 10:29
  • `CONVERT` function will do on all earlier versions , but i also used that `FORMAT` function because i am using 2012 :) – japzdivino Nov 24 '15 at 10:38