retrive the records between two dates in uk standard format

  • Hi,

    I wanted to retrive the records from the data base between two dates selected from 2 calendars.

    The date format is in uk standard.Can any one please send me the solution for this?Thanks in advance.

    Regards,

    Pallavi.

  • I presume that the date in DB is in string format.

    Please refer to the following code:

    Declare @FromDate Varchar(10)

    Declare @ToDate Varchar(10)

    Set @FromDate = '1/5/2008'

    Set @ToDate = '31/7/2008'

    Create table #TT

    (

    ID Int,

    Date Varchar(20)

    )

    Insert Into #TT

    Select 1, '10/5/2008'

    Union

    Select 2, '5/10/2008'

    Union

    Select 3, '31/7/2008'

    select * From #TT

    Where convert(datetime,Date,103) BetWeen convert(datetime,@FromDate,103) And convert(datetime,@ToDate,103)

    Change this code to use your table and i guess you will be OK. The convert with 103 will convert the string to British format date.

    Hope it works!

  • Hi,

    Thank you very much for your reply.I used that code ,it works fine.I amso happy.

    Regards,

    Pallavi.

  • pallavikiran.deevi (6/10/2008)


    Hi,

    Thank you very much for your reply.I used that code ,it works fine.I amso happy.

    Regards,

    Pallavi.

    It would be better, in the long run, to change the Date column in the table to a DateTime datatype.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

  • Thanks 🙂

    Abhay Jain

    Swastik Info solutions

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

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