Reputation: 1203
In my existing SQL Server database, there is a column like this:
meeting_time varchar(22)
02:30:PM
Now I want to convert it into 24 hours format. i.e., it should convert to 14.30
When I tried this:
SELECT
CONVERT(VARCHAR(8), meeting_time, 1)
FROM
group_info
WHERE
MGI_Id = 1
It will return the same value which stored in this column. When I tried with converting it into time or datetime, it throws exception.
Can anyone please help me!
Thanks in advance.
Upvotes: 0
Views: 343
Reputation: 12318
This should work:
select convert(time, stuff(meeting_time, 6, 1, ' '))
Not sure if it works with all locales / languages, so you should check that first.
This assumes that your date is always in the same format, that the extra :
is in the 6th character.
Upvotes: 2