create table with fields ID, reserved_by,res_date
res_date is datefield like 2010-03-09 00:00:00.000 from
2005 to 2006 any date assume
based on res_date need to slect table and display
based on month (full jan details in database irrespective
of date and year

Answer Posted / sandip

//Show records for a given month
SELECT * FROM table_name (NOLOCK)
WHERE SUBSTRING(res_date, 6, 2) = (numeric value for month.
eg 01 for Jan)


//Show all the records sorted by res_date based on month.
SELECT * FROM table_name (NOLOCK)
ORDER BY SUBSTRING(res_date, 6, 2) ASC

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are indexes in sql?

770


Explain some stored procedure creating best practices or guidelines?

680


What is the purpose of the master database?

815


List the various tools available for performance tuning?

641


What it means to be triggered?

662






How to divide query output into multiple groups with the group by clause in ms sql server?

746


What is row-level compre?

716


What is difference between rownum and row_number?

696


Create a dts package to produce a text file using the ‘update statistics’ command for the tables in a database with obsolete statistics.

703


Explain can you implement data mining in ssrs?

122


What does <> symbol mean?

705


What do you mean by table and field in sql?

741


What are the advantages of using stored procedures in sql server?

699


what are the different types of replication you can set up in sql server? : Sql server database administration

746


What is compound operators?

709