SQL Server simple time format function?

Posted on 2005-05-13
Medium Priority
Last Modified: 2010-03-19
Is their a built in function in SQL SErver which would allow me to make sure the
time my user enters is in the format 4:00pm

Really all I need is the ability to SELECT this format
Question by:dylanone
LVL 21

Expert Comment

ID: 13998892
Seems like the sort of thing you should handle in the application....your users aren't entering data directly through Enterprise Manager are they?
LVL 75

Accepted Solution

Anthony Perkins earned 200 total points
ID: 13998903
>>Is their a built in function in SQL SErver which would allow me to make sure the
time my user enters is in the format 4:00pm <<
If you are asking about validating input, than this is the responsibility of the presentation layer not the database.  If all you want to see is the time using a date time column than you can use:

Select RIGHT(CONVERT(varchar(30), getdate(), 100), 7)

Author Comment

ID: 13998981
In this case my users enter data into the content management tool - then at that point I run selects and verify the data on the record currently being enetered - if a problem occurs - the system has built in error messages

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

831 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