Compare Table date with current date

  • Christopher Stobbs (4/21/2009)


    I agree 100% 🙂 I think the tools for your solution have now been provided and working out the last part will provide a good learning platform for you to get a good understanding of what we have shared 🙂

    yes... I figured out the solution. Thks for the help.

  • Could you post the solution?

    this will help any others searching for a similar solution 🙂

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • Christopher Stobbs (4/21/2009)


    Could you post the solution?

    this will help any others searching for a similar solution 🙂

    well I just did this.

    where table.column1 = 'xxx' and (column2 between getdate() -7 and getdate())

    column1= text column

    column2= smalldatetime column

  • just remember that your solution does not take into account time.

    so for example if you run the query at 2009-04-21 16:38.59

    Then anything before 16:38.59 on the 2009-04-14 will not be included.

    If you happy with that then great 🙂

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • Christopher Stobbs (4/21/2009)


    just remember that your solution does not take into account time.

    so for example if you run the query at 2009-04-21 16:38.59

    Then anything before 16:38.59 on the 2009-04-14 will not be included.

    If you happy with that then great 🙂

    you are right, I will try other solution.

    Other thing that I figured that i will need is that I will need to show to all the records between last month and the current date, and the last year and current date.

    I made this change to the query

    DATEADD(mm, DATEDIFF(mm,0,DATEADD(mm,-1,GETDATE())), 0)

    and getdate())

    but i need to figure a solution because, i only need to count 1 month back from the current date, and for the year i will need to count 1 year from the current date.

    I will post the solution when i figure that out.

    thks again

Viewing 5 posts - 16 through 19 (of 19 total)

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