Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Convert DateTime to just time

Posted on 2004-11-11
2
Medium Priority
?
8,177 Views
Last Modified: 2008-01-09
Hi,

I have a DATETIME field:

SELECT DATEFIELD
FROM TABLE1

DATEFIELD has fields like: 11/11/2004 10:20:32 PM
How would I remove the date part (11/11/2004) and keep only the time, but strip out the AM and PM and also the colons ":"?

So that DATEFIELD will only return:

102032

Thanks!

Chris
0
Comment
Question by:Trancedified
2 Comments
 
LVL 32

Accepted Solution

by:
Brendt Hess earned 2000 total points
ID: 12558054
Try:

SELECT Replace(Convert(varchar, DATEFIELD, 108), ':', '') AS TimeField
0
 
LVL 1

Author Comment

by:Trancedified
ID: 12558144
bhess1,

Yep just what i needed. Thanks!

Chris
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

578 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