Simple Query Help Needed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • emanuel.levy@gmail.com

    #1

    Simple Query Help Needed

    I have a table called tbl_employers. One of the fields is start_date.
    I'm trying to make a query that will show all entries where todays date
    is 275 days and 305 days after the start date.

    Any help would be appreciated

  • fredg

    #2
    Re: Simple Query Help Needed

    On 3 Nov 2005 08:20:23 -0800, emanuel.levy@gm ail.com wrote:
    [color=blue]
    > I have a table called tbl_employers. One of the fields is start_date.
    > I'm trying to make a query that will show all entries where todays date
    > is 275 days and 305 days after the start date.
    >
    > Any help would be appreciated[/color]

    Do you mean between 275 and 305 days?

    Select tbl_employers.* From tbl_employers
    Where tbl_employers.[Start_Date] Between DateAdd("d",-275,Date()) and
    DateAdd("d",-305,Date())

    or exactly 275 and exactly 305 days?

    Select tbl_employers.* From tbl_employers
    Where tbl_employers.[Start_Date] = DateAdd("d",-275,Date()) Or
    tbl_employers.[Start_Date] = DateAdd("d",-305,Date())

    --
    Fred
    Please respond only to this newsgroup.
    I do not reply to personal e-mail

    Comment

    • emanuel.levy@gmail.com

      #3
      Re: Simple Query Help Needed

      Good point. I was planning on having them run the query every day but
      that would not cover weekends.

      Basically I needed a query that shows what entries are 90 days from
      expiration , what ones are 60 days from expiration and what ones are
      365 days or more.

      The 365 or more was easy it's the other two that are causing problems
      for me. I'll try your code samples. I'm using

      DateDiff("d",[SHARP Begin Date],Now())
      Then using >=365 for the expired ones
      [color=blue]
      >=274 for the 90 Day warnings which also bring the ones that are over a year old and I don't want them[/color]

      and lastly
      [color=blue]
      >=305 for the 60 day warnings which is also bringing the ones that expire in 90 days and expired ones.[/color]

      Comment

      • fredg

        #4
        Re: Simple Query Help Needed

        On 3 Nov 2005 12:47:51 -0800, emanuel.levy@gm ail.com wrote:
        [color=blue]
        > Good point. I was planning on having them run the query every day but
        > that would not cover weekends.
        >
        > Basically I needed a query that shows what entries are 90 days from
        > expiration , what ones are 60 days from expiration and what ones are
        > 365 days or more.
        >
        > The 365 or more was easy it's the other two that are causing problems
        > for me. I'll try your code samples. I'm using
        >
        > DateDiff("d",[SHARP Begin Date],Now())
        > Then using >=365 for the expired ones
        >[color=green]
        >>=274 for the 90 Day warnings which also bring the ones that are over a year old and I don't want them[/color]
        >
        > and lastly
        >[color=green]
        >>=305 for the 60 day warnings which is also bringing the ones that expire in 90 days and expired ones.[/color][/color]

        Using Now() in the expression is not a good idea.
        Now() includes a time value, therefore the number of records returned
        will depend upon the time of day the query is run.
        Use Date() instead.

        --
        Fred
        Please respond only to this newsgroup.
        I do not reply to personal e-mail

        Comment

        • emanuel.levy@gmail.com

          #5
          Re: Simple Query Help Needed

          Thank you for thaty suggestion I'm going to change them to Date.

          How would I write the expression 61 to 90 days instead of just 90 days?

          Comment

          • emanuel.levy@gmail.com

            #6
            Re: Simple Query Help Needed

            Scratch that. I figured out I can use <= at the end of the expression
            to limit what shows and it all looks good.

            Thanks for all the help Fred. I hope this helps others as well

            Comment

            Working...