Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2013
    Posts
    12

    Unanswered: 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

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    If you want to do a date comparison use datetime data types and not varchar.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Jan 2013
    Posts
    354
    Provided Answers: 1
    Why are you treating dates as strings? That was COBOL, not SQL. Google the Calendar table and use it.

    CREATE PROCEDURE Date_List
    (@in_start_date DATE,
    @in_end_date DATE)
    AS
    SELECT cal_date
    FROM Calendar
    WHERE cal_date BETWEEN @in_start_date AND @in_end_date DATE;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •