Solved

Query: How to select Time only from a datetime field?

Posted on 2004-09-21
4
430 Views
Last Modified: 2008-02-07
How to select only time from a datetime field?

I have a datetime field named SentTime.
I only want to select the Time from the field..

sample data of TimeSent:
21/09/2004 12:58:41 PM

But I only want to select 12:58:41 PM...
how to do it?
0
Comment
Question by:p931226
  • 2
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
appari earned 30 total points
ID: 12119744
use convert function.

eg:
select convert(varchar,getDate(),108)

in your sql

Select convert(varchar,SentTime,108) from yourTable
0
 

Author Comment

by:p931226
ID: 12119825
Hi, appari
I follow ur method, it shown
19:00:00

Any method that will make it shown like:
07:00:00 PM ???

Thanks.

0
 
LVL 39

Expert Comment

by:appari
ID: 12119901
i think no direct way
try like this

select substring(convert(varchar,getdate(),100),13,9)
0
 

Author Comment

by:p931226
ID: 12120026
thanks, appari..
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

Suggested Solutions

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

707 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

13 Experts available now in Live!

Get 1:1 Help Now