Below is the sql query I have wrote to populate year- month but it generates random. I want it to be like Jan -15, feb -15 ........dec-15, jan-16............dec-16....
SELECT
CASE WHEN dbo.X_HIST_VASCULAR.MONTH = 'January' then 'Dec ' + convert(char(2),dbo.X_HIST_VASCULAR.YEAR-2001)
WHEN dbo.X_HIST_VASCULAR.MONTH = 'February' then 'Jan ' + convert(char(2),dbo.X_HIST_VASCULAR.YEAR-2000)
WHEN dbo.X_HIST_VASCULAR.MONTH = 'March' then 'Feb ' + convert(char(2),dbo.X_HIST_VASCULAR.YEAR-2000)
WHEN dbo.X_HIST_VASCULAR.MONTH = 'April' then 'Mar ' + convert(char(2),dbo.X_HIST_VASCULAR.YEAR-2000)
WHEN dbo.X_HIST_VASCULAR.MONTH = 'May' then 'Apr ' + convert(char(2),dbo.X_HIST_VASCULAR.YEAR-2000)
WHEN dbo.X_HIST_VASCULAR.MONTH = 'June' then 'May ' + convert(char(2),dbo.X_HIST_VASCULAR.YEAR-2000)
WHEN dbo.X_HIST_VASCULAR.MONTH = 'July' then 'June ' + convert(char(2),dbo.X_HIST_VASCULAR.YEAR-2000)
WHEN dbo.X_HIST_VASCULAR.MONTH = 'August' then 'July ' + convert(char(2),dbo.X_HIST_VASCULAR.YEAR-2000)
WHEN dbo.X_HIST_VASCULAR.MONTH = 'September' then 'Aug ' + convert(char(2),dbo.X_HIST_VASCULAR.YEAR-2000)
WHEN dbo.X_HIST_VASCULAR.MONTH = 'October' then 'Sep ' + convert(char(2),dbo.X_HIST_VASCULAR.YEAR-2000)
WHEN dbo.X_HIST_VASCULAR.MONTH = 'November' then 'Oct ' + convert(char(2),dbo.X_HIST_VASCULAR.YEAR-2000)
WHEN dbo.X_HIST_VASCULAR.MONTH = 'December' then 'Nov ' + convert(char(2),dbo.X_HIST_VASCULAR.YEAR-2000)
END
FROM
dbo.X_HIST_VASCULAR
So. If i query Month select distinct month from x_hist_vascular This is the results i get month February June August April May December January September October July November March
If i do Asc or Desc it goes throw alpha order. Like for Asc it display April first and for Desc it displays September. I want months to be displayed in calendar format.
dbo.X_HIST_VASCULAR
have a DateTime column with the date in? – Andrew Morton