Friday, February 10, 2012

Convert Date Format from 23 Aug 07 to mm-dd-yy

I have this stored procedure, and im trying to figured out how i can convert the date field into something i can actually sort in the right order in reporting services. Such as mm-dd-yy , whats the SQL code for doing that?

Give a look to the CONVERT-->CAST AND CONVERT article in books online; there is a section that deals with particular format flavors for DATE/TIME datatypes. The mm/dd/yyyy format is the "101" flavor. That function reference will look something like:

CONVERT(VARCHAR(10), yourDateVar, 101)

|||

I just realized this month comes from a view that has month put together by two fields. It looks like this

CONVERT(char(12), DATEADD(day, dbo.question_history.cycle_day - 1, dbo.period.start_date)

The period starte date looks like this 2007-07-16 00:00:00.000

The date is actually the period start date plus + the cycle day - 1. ITs confusing i know. So how come when i try to edit the date it wont let me, i get this 39280 for some weird reason.

No comments:

Post a Comment