Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 datetime conversion

Author  Topic 

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2007-02-06 : 03:49:27
hi, i need to convert datetime as dd/mm/yy hh:mi:ss:mmmAM format,so i used this:
select convert(varchar(20),getdate(),131)
19/01/1428 2:20:22:

i need 06/02/2007 2:20:22pm how to get please tel me

Kristen
Test

22859 Posts

Posted - 2007-02-06 : 03:54:37
Normally this is done in the Client / Application and not in SQL Server.

Kristen
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-06 : 04:01:40
If you don't know how to do it in front-end, use this
select convert(varchar, getdate(), 103) + ' ' + right('0' + stuff(right(convert(varchar, getdate(), 109), 14), 8, 4, ''), 10)


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2007-02-06 : 04:04:11
select left(convert(varchar(20),getdate(),103),10) + ' ' + ltrim(stuff(right(convert(varchar(40),getdate(),109),15),10,4,''))

Doesn't want the leading 0.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

sqllover
Constraint Violating Yak Guru

338 Posts

Posted - 2007-02-06 : 04:10:27
hi nr and peso thank you very much
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-06 : 04:10:49
Oh...


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2007-02-06 : 10:00:11
I'd already written it so wanted an excuse to postit.
Surprising how close it was to yours.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -