Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to get record from fromdate to todate

Author  Topic 

suguna
Starting Member

6 Posts

Posted - 2009-06-20 : 03:11:09
hai,

I am using one table,
select * from CC_Number


id fromdate todate
1 2009-06-06 00:00:00.000 2009-06-06 00:00:00.000
2 2009-06-07 00:00:00.000 2009-06-07 00:00:00.000
3 2009-06-08 00:00:00.000 2009-06-08 00:00:00.000

I am using below Query,

select * from CC_Number where fromdate='6/6/2009' and todate='6/7/2009'

I got No result.But I need below result,

id fromdate todate
1 2009-06-06 00:00:00.000 2009-06-06 00:00:00.000
2 2009-06-07 00:00:00.000 2009-06-07 00:00:00.000


how to get?If know the answer replay to me.
Thanks in Advance.










ss

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-20 : 03:13:22
[code]select * from CC_Number where fromdate>='6/6/2009' and todate<='6/7/2009'[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-06-20 : 03:16:11
if by any chance you've value for timepart also then you need a slight tweake to include records of 7/6 with non zero time part

select * from CC_Number where fromdate>='6/6/2009' and todate<'6/8/2009'
Go to Top of Page

suguna
Starting Member

6 Posts

Posted - 2009-06-20 : 05:06:42
hai khtan,

Thanks for your Replay.I got Result from below query,

select * from CC_Number where fromdate='6/6/2009' or todate='6/7/2009'

ss
Go to Top of Page

suguna
Starting Member

6 Posts

Posted - 2009-06-20 : 05:08:01
hai visakh,

Thanks for your Replay I got Result from this below query,


select * from CC_Number where fromdate='6/6/2009' or todate='6/7/2009'

ss
Go to Top of Page

Jeff Moden
Aged Yak Warrior

652 Posts

Posted - 2009-06-21 : 18:50:26
Uh huh... and what are you going to do if you need to find dates from 6/6 to 6/19? Lemme guess... that'll never happen, right?

--Jeff Moden
"Your lack of planning DOES constitute an emergency on my part... SO PLAN BETTER! "
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row"

For better, quicker answers, click on the following... [url]http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]
Go to Top of Page
   

- Advertisement -