This is close:
declare @d datetime
set @d = '22 Jan 2009 6:00'
SELECT convert(char(10),@d,101) +
RIGHT(convert(char(19),@d,100),
This returns 01/22/2009 6:00AM. It matches what you requested, with
the exception of the space before the am/pm. It differs from your
sample result in that it has the leading zero on the month and two
spaces between the year and hour when the hour is not two digits.
Roy Harvey
Beacon Falls, CT
On Tue, 29 Apr 2008 02:05:44 GMT, "balajikkrishnan via SQLMonster.com"
wrote:
>Hi All,
>
>Can any one tell me how to format the date time in tsql in this format
>
>mm/dd/yyyy hh:mm am/pm (1/22/2009 6:00am)
>
>Thanks
>Balaji