date between in procedure

  • 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

  • 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

  • thanks for response

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply