Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 [Resolved] Extract Time from Date/Time Field

Author  Topic 

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2008-08-12 : 16:31:06
I need to extract the time only from a date/time field (dbo.EmployeeTimeEvent.Time). If I need to is it possible also to set the time in AM/PM instead of military time?

select	dbo.Batch.ReportDate as job_date, 
dbo.EquipmentLaborEvent.Hours as equipment_hours,

dbo.EmployeeTimeEvent.Time as event_time,

substring(dbo.EmployeeTimeEventType.Name, 1, 20) as event_type

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-08-12 : 16:34:16
Use CONVERT function with the appropriate style.

Or better yet, do this in your application and not in T-SQL as this is a presentation issue.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2008-08-12 : 16:59:44
Hi tkizer,
Good idea, I will do it my presentation program. Thank you.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-14 : 06:22:07
quote:
Originally posted by snufse

Hi tkizer,
Good idea, I will do it my presentation program. Thank you.


After a long time I'm seeing a person admitting to do formation at front end

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-14 : 06:23:53
quote:
Originally posted by madhivanan

quote:
Originally posted by snufse

Hi tkizer,
Good idea, I will do it my presentation program. Thank you.


After a long time I'm seeing a person admitting to do formation at front end

Madhivanan

Failing to plan is Planning to fail


Victory for Madhi
Go to Top of Page
   

- Advertisement -