Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

does time(7) need to be in military time

Posted on 2014-04-29
7
Medium Priority
?
334 Views
Last Modified: 2014-04-30
In the database, I have a column set to time(7)

Do time values always have to be in military time.  Can't they be in the normal time?
0
Comment
Question by:al4629740
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 12

Accepted Solution

by:
duttcom earned 2000 total points
ID: 40030942
The time format is HH:MM:SS and as such there is no value for a.m. or p.m. that would allow you to use 12 hour time instead of 24 hour time.
0
 

Author Closing Comment

by:al4629740
ID: 40030951
So the answer is no.
0
 
LVL 12

Expert Comment

by:duttcom
ID: 40030954
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:al4629740
ID: 40030960
It might be too complicated for me to do it.  I just need a datatype to show it.
0
 
LVL 12

Expert Comment

by:duttcom
ID: 40030972
Try something like this in your select statement -

select CONVERT(varchar(15),YourTimeField,100) as YourTimeField
0
 

Author Comment

by:al4629740
ID: 40031016
Yes, thank you.  The main objective was to have it displayed inherently in the table.

Again.  Thanks
0
 
LVL 49

Expert Comment

by:PortletPaul
ID: 40031419
>> "The main objective was to have it displayed inherently in the table."

not sure what "displayed inherently" means, but a Time(7) field is NOT stored "in a format" at all. Date/Time information is actually stored as integers, but presented to us mere humans in a fashion that we comprehend as dates and/or times. e.g.

select YourTime7_field from yourtable;

will display a "default" time format, probably HH:MM;SS +0000000 and I don't think that default can be altered. You can however specify the format you want to see using convert e.g.
    CREATE TABLE Table1
    	([MyTime7] time(7))
    ;
    	
    INSERT INTO Table1
    	([MyTime7])
    VALUES
    	('23:35:45')
    ;

**Query 1**:

    select
      MyTime7
    , convert(varchar, MyTime7 ,9) am_pm_full_precision
    from table1
    

**[Results][2]**:
    
    |          MYTIME7 | AM_PM_FULL_PRECISION |
    |------------------|----------------------|
    | 23:35:45.0000000 |   11:35:45.0000000PM |



  [1]: http://sqlfiddle.com/#!6/2fd45/8

Open in new window

also see http://www.experts-exchange.com/Database/MS-SQL-Server/A_12315-SQL-Server-Date-Styles-formats-using-CONVERT.html
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

636 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