Click here to Skip to main content
15,918,267 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
out put can given
======================
Month
Nov
Dec
Jan



Given this format out put
======================
Month
Jan
Feb
..
Order by



used this query
================
SQL
SELECT DISTINCT DATENAME(month, STR(YEAR(StudentAttendanceDate), 4) + REPLACE(STR(CurrentMonth, 2), ' ', '0') + '01')as Months
from tbl_StudentAttendanceMaster
order by Months
Posted
Comments
Jeet Gupta 13-Jan-15 0:18am    
what exactly you want. doesn't understand your question properly
Magic Wonder 13-Jan-15 7:04am    
Your question is not clear. What exactly are you looking for? Output should be sorted like "Jan, Feb, Mar" or "Dec, Jan, Feb"? Also share your table structure.

SQL
SELECT distinct  DATENAME(month, StudentAttendanceDate) AS 'Month Name'from tbl_StudentAttendanceMaster
order by [Month Name]
 
Share this answer
 
If you have only month names with you,you can try below

SQL
Create  table #table(MonthNames varchar(12))
insert #table select 'Jan'
insert #table select 'Mar'
insert #table select 'Feb'


select MonthNames
from #table
Order by convert(Date,MonthNames+' 01 1900')
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900