Results 1 to 6 of 6
  1. #1
    Lounger
    Join Date
    Jun 2002
    Location
    RTP, NC, USA
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    DatePart ((Access97))

    Hi,
    I'm trying to compare the dates (month and day) in a table to today's date (month and day) and perform a function on any matches. I've got the following code, but can't seem to quite get the SQL down exactly. Would someone mind helping me clean it up so it performs the function?

    SELECT tblA.Number, tbA.Product, tblA.ApprovalDate
    FROM tblA
    WHERE (((DatePart ("m", tblA.ApprovalDate)) and (DatePart ("y", tblA.ApprovalDate)))= (DatePart ("m", Date() )));


    Thanks in advance,
    Marc

  2. #2
    Lounger
    Join Date
    Jun 2002
    Location
    Anderson, Indiana, USA
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DatePart ((Access97))

    maybe your year part need four y's ....like yyyy

  3. #3
    Lounger
    Join Date
    Jun 2002
    Location
    Anderson, Indiana, USA
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DatePart ((Access97))

    maybe your year part need four y's ....like yyyy and or if your trying to match a day maybe the y should be a d

  4. #4
    Lounger
    Join Date
    Jun 2002
    Location
    RTP, NC, USA
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DatePart ((Access97))

    tried both of those suggestions, and neither seems to work. basically what i'm trying to do is to look at the dates that something was submitted (in previous years) and see if today's date matches the anniversary of one of those submission dates...then perform a function on the result. That's why i've chosen to exclude the year. maybe there's a different command that I'm unaware of that might serve my purpose better.

  5. #5
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DatePart ((Access97))

    When I used the following WHERE clause, all records for August 29th of any year were returned:
    WHERE (((DatePart("m",[tblA].[ApprovalDate]))=(DatePart("m",Date()))) AND ((DatePart("d",[tblA].[ApprovalDate]))=(DatePart("d",Date())));
    If that is what you wanted, you don't need to address the year, but you do need to address the day along with the month in your clause.

  6. #6
    Lounger
    Join Date
    Jun 2002
    Location
    RTP, NC, USA
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: DatePart ((Access97))

    got it...

    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
  •