C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » SQL Server »

DateTime


Posted Date: 01 Nov 2009      Posted By: Naresh      Member Level: Silver     Points: 1   Responses: 6



Hi All,


i want to getdata from table for partcicular dates
select * from table where OrderDate='1/31/2009')it is not working.i will give both fromdate and todate.i should get all the data betwenn this dates it should include fromdate and todate data also





Responses

Author: Mohan    01 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

try this

select * from table where OrderDate>='1/1/2009' and Orderdate<='1/31/2009'

Regards

Mohan Kumar.D



Author: greeny_1984    01 Nov 2009Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

Hi,

You can check out 'between' operator in sql server to achieve

your functionality.

Regards,
Greeny_1984

Rate this Response[Excellent/Good/Poor]
FRESHERS check this link
Need help from me join here



Author: Melchior    01 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

Instead of using BETWEEN operator,Mohan response is ok.
Because SQL SERVER will transform Between operator into (>= AND <=) format. To improve the performance,don't use costly operator like BETWEEN.



Author: Manick    01 Nov 2009Member Level: GoldRating: 2 out of 52 out of 5     Points: 2

select * from table_name where OrderDate BETWEEN 'From_date' and 'To_date'

Regards,
Manick



Author: Shameer    03 Nov 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

In some databases, the BETWEEN operator only selects fields that are between and excluding the test values. So instead of BETWEEN use comparison operator(<,>) , you will get the correct answer.


Author: sudha    12 Nov 2009Member Level: SilverRating: 2 out of 52 out of 5     Points: 2

SELECT * from [tablename] where date BETWEEN 'from-date' and 'to-date';


Post Reply
You must Sign In to post a response.
Next : Sql Server performance
Previous : Last affected row
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use