troubleshooting Question

SQL Time Format

Avatar of r_lynn
r_lynnFlag for United States of America asked on
Microsoft SQL ServerMicrosoft SQL Server 2008
9 Comments1 Solution347 ViewsLast Modified:
OK, I am banging my head on something which should be simple!
I am creating a SQL statement to display information from an appointments database.  The data fiels I am reading is formatted 'yyyy-mm-dd" (1900-01-01 09:30:00.000).  The date extraction was easy enough for me but the time format I need is eluding me.  The time needs to be formatted 'hh:mm AM(or PM)'

SELECT        PatientID, DoctorID, OfficeID, CONVERT(varchar(10),Date,101)AS Date, time, DurationInMinutes, Cancelled, NewPatientLast, NewPatientFirst, NewPatientMI, Comments
FROM            Appointments
WHERE        (Date = CONVERT(DATETIME, '2011-09-30', 102)) AND (PatientID > 0)

PatientID	DoctorID	OfficeID	Date	time	DurationInMinutes	Cancelled	NewPatientLast	NewPatientFirst	NewPatientMI	Comments
75044	5	1	09/30/2011	1900-01-01 07:55:00.000	5	0	NURSE                     	NULL	NULL	NO LASER HAIR IN SEPT

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 9 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros