December 19, 2013 at 3:59 am
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
December 19, 2013 at 4:43 am
You can make them parameter
alter procdure date
@Fromdate varchar(10),
@todate varchar(10)
AS
--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
Regards,
Mitesh OSwal
+918698619998
December 19, 2013 at 5:24 am
thanks for response
December 19, 2013 at 5:29 am
Don't convert dates to strings for comparisons, just going to make a mess. Compare dates with dates, it's efficient and you're not going to run into problems with formats
Are you sure you're looking for rows where the @FromDate is greater than the @ToDate and less than the column value Original Date?
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply