Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    133

    Wink Unanswered: newbie question: query only the records are in current month

    I've tried out in query's criteria of date filed: "month(now())", but it not works.
    Could you guide me how to query only the records of current month?
    For example:
    In case of this month: I only want the record for August. But in case of next month, I only want the records for September.
    many thanks. I need your help.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select foo, bar
      from yourtable
     where datecolumn
      between dateadd("d", -day(date())+1, date())
          and dateadd("d", -1,
              dateadd("m", 1,
              dateadd("d", -day(date())+1, date())))
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    May 2004
    Posts
    133
    Thanks you a lot for the answer. I'll try it later and reply you soon.
    many thanks.

  4. #4
    Join Date
    May 2004
    Posts
    133
    thanks you, r937. the code you provided me works fine.
    once again, thanks.

Posting Permissions

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