• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 580
  • Last Modified:

Convert Time from Nvarchar String to Military Time

Hi There,

I have a ncharvar column in a SQL table that shows the time as 3:10 PM or 11:35 AM. I need to convert this to military time string format like 1510 and 1135. Any help on this is much appreciated.
Thanks
0
salhus
Asked:
salhus
  • 2
2 Solutions
 
gplanaCommented:
What RDBMS are you using ? If you are using SQL-Server, you should see the convert funcion: http://msdn.microsoft.com/es-es/library/ms174450%28SQL.90%29.aspx

If you are using Oracle, you should see TO_DATE function: http://www.oradev.com/oracle_date_format.jsp
0
 
salhusAuthor Commented:
Thanks for the quick response. I got the desired result using the following conversion..

(CONVERT(varchar,(CONVERT(integer,(substring(PM_TIME,2,1))) + 12))) +  SUBSTRING(PM_TIME,4,2)
0
 
salhusAuthor Commented:
resolved
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now