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
 date between in procedure

Author  Topic 

rajnidas
Yak Posting Veteran

97 Posts

Posted - 2013-12-19 : 05:45:47

hi every one,

i need procedure query for two date between fromdate and todate


pls. i need help


alter procdure date

declare @Fromdate varchar(10)
declare @todate varchar(10)
as begin

select * from master
where convert(varchar(10),@Fromdate,121) between CONVERT(varchar(10),@Todate,121) and CONVERT(varchar(10),rr.Original_Date,121)

end


Thanks

Rajnidas

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-12-19 : 06:15:31
Check this link for Date Range Comparisons in SQL Server
http://visakhm.blogspot.in/2012/12/different-ways-to-implement-date-range.html

--
Chandu
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-12-19 : 06:29:43
What is the Datatype of Original_date column?
Why are you set @FromDAte & @ToDate types as VARCHAR(10)? Better to have DATETIME data type
--Sample
declare @Fromdate DATE = '2013-12-19'
declare @todate DATE = '2013-12-20'
select *
from test1223
where c1 BETWEEN @Fromdate AND @Todate


--
Chandu
Go to Top of Page

rajnidas
Yak Posting Veteran

97 Posts

Posted - 2013-12-19 : 07:24:28
thanks for your response
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2013-12-24 : 07:21:02
If the time part is included in the dates, use

select *
from test1223
where c1 >=@Fromdate AND c1< dateadd(day,1,@Todate)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -