Solved

Convert Time from Nvarchar String to Military Time

Posted on 2010-09-06
3
558 Views
Last Modified: 2012-06-21
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
Comment
Question by:salhus
  • 2
3 Comments
 
LVL 15

Assisted Solution

by:gplana
gplana earned 125 total points
ID: 33613376
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
 

Accepted Solution

by:
salhus earned 0 total points
ID: 33621149
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
 

Author Closing Comment

by:salhus
ID: 34082778
resolved
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I guess that all of us know that caching the data usually increase the performance, but I worried if all of us are aware about the risk that caching the data provides and how to minimize this.  That’s the reason why I decided to write this short art…
SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now