-
Format Time in a Query
In my table in SQL 2005 it has the date and time in the field. Example: 3/7/2007 9:14:00 AM. The question I have is how do you format this field so it displays 09:14:00 AM?
-
Can try:
convert(char(12), col_name, 108)
-
That gives me 11:19:15 but no AM/PM
-
131 returns AM/PM but in dd/mm/yyyy format
select convert(char(26),getdate(),131)
There are several styles supported with CONVERT function, check BOL.
-
There is no such style in convert function, may need use substring to get what you want.
-
Hi,
SELECT Substring('3/7/2007 9:14:00 AM', (CHARINDEX(' ','3/7/2007 9:14:00 AM'))+1, (CHARINDEX(' ','3/7/2007 9:14:00 AM'))+3)
-
The thread is almost 2 years old.
-
sorry i didnt check the date
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|