Between dates (dd-mm) query MS Access

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alain Filiatrault

    Between dates (dd-mm) query MS Access

    HI,

    I'm having a problem with the following query.

    Here it is in my own words :

    Table :
    T_Test
    id (Autonumber)
    dtmStartDate (Datetime) format dd-mm
    dtmEndDate (datetime) format dd-mm
    intHours (number)

    I want to query the T_Test table with a dd-mm value to get the right
    intHours value where my dd-mm is between dtmStartDate and dtmEndDate.

    Select intHours from T_Test where '25-05' between dtmStartDate and
    dtmEndDate

    Can someone help please?

    Thanks

    Alain
  • Wayne Morgan

    #2
    Re: Between dates (dd-mm) query MS Access

    A date includes a date, month, and year. While you could use the format
    command to format the field and criteria the same, it would return the month
    and day, regardless of year. This will probably cause you a problem when you
    continue to add records next year. The criteria will work properly if you
    include the year also. If you simply want the current year, you can
    concatenate that in.

    Select intHours from T_Test where DateSerial(Year (Date()), 05, 25) between
    dtmStartDate and dtmEndDate

    --
    Wayne Morgan
    Microsoft Access MVP


    "Alain Filiatrault" <alainf@humapri se.com> wrote in message
    news:45d95216.0 404290509.79211 dc5@posting.goo gle.com...[color=blue]
    > HI,
    >
    > I'm having a problem with the following query.
    >
    > Here it is in my own words :
    >
    > Table :
    > T_Test
    > id (Autonumber)
    > dtmStartDate (Datetime) format dd-mm
    > dtmEndDate (datetime) format dd-mm
    > intHours (number)
    >
    > I want to query the T_Test table with a dd-mm value to get the right
    > intHours value where my dd-mm is between dtmStartDate and dtmEndDate.
    >
    > Select intHours from T_Test where '25-05' between dtmStartDate and
    > dtmEndDate
    >
    > Can someone help please?
    >
    > Thanks
    >
    > Alain[/color]


    Comment

    Working...