1

I know there are several questions similar to mine, but I need specifics. Using SQL in Microsoft Query, I have a time column that produces a result like 1900-01-01 13:30:00:0000000 and I need to convert it to produce only a 1:30PM result.

Now, my column is ODS_COURSE_SECTION_MTG.CSM_START_TIME so I need to know, when I'm in "Edit Column" where and exactly what in the "Field" to type.

I have done

CONVERT(TIME, ODS_COURSE_SECTION_MTG.CSM_START_TIME)

but that only produces a 13:30:00:0000000 result.

Please help! Please tell me exactly how to edit that column to get the 1:30PM result.

Thank you in advance!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

2

Is the data stored as a TIME field? If so then this should work (full example so you can see what I mean):

DECLARE @t TIME
SET @t = GETDATE()
SELECT CONVERT(VARCHAR, @t, 100)

So your code should be:

SELECT CONVERT(VARCHAR, ODS_COURSE_SECTION_MTG.CSM_START_TIME, 100)
Tom Chantler
  • 14,753
  • 4
  • 48
  • 53
  • 2
    I also keep this link bookmarked for quick reference... http://msdn.microsoft.com/en-us/library/ms187928.aspx – sam yi Aug 21 '12 at 23:33