Results 1 to 2 of 2
  1. #1
    kaylachris is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2010
    Posts
    21

    Help with SQL: Birthdays in Next 30 days

    I am attempting to create a query which determines what birthdays are coming up in the next 30 days... I've managed to create such a query that works but there is a major flaw.. It doesn't carry on to the next year.



    Code:
     
    SELECT SoliderData.Rank, SoliderData.LastName, SoliderData.FirstName, SoliderData.MiddleInitial, SoliderData.Sex, SoliderData.DOB, SoliderData.Section, SoliderData.Platoon, DateSerial(Year(Date()),Month([DOB]),Day([DOB])) AS Birthday
    FROM SoliderData
    WHERE ((Not (SoliderData.DOB) Is Null) 
    AND ((DateSerial(Year(Date()),Month([DOB]),Day([DOB]))) Between Date() And Date()+30));
    I've have tried changing the WHERE clause to the following to attempt to include the the beginning of the year but get a "Data type Mismatch in criteria expression" error. Actually if I attempt to put any type of OR statement I get the same error... even if I copy the good line.

    Code:
    WHERE ((Not (SoliderData.DOB) Is Null) 
    AND DateSerial(Year(Date()),Month([DOB]),Day ([DOB])) Between Date() and Date() + 30
    OR DateSerial(Year(Date()),Month([DOB]),Day ([DOB]))
    Between DateAdd("yyyy",1,Date()) and DateAdd("yyyy",1,Date()) + 30
    I'm Lost HELP!!

  2. #2
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2003
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    Try this:

    Code:
    WHERE ((Not (SoliderData.DOB) Is Null) 
    AND (((IIf(Month([DOB])=1,DateDiff("d",Date(),DateSerial(Year(Date())+1,Month([DOB]),Day([DOB]))),DateDiff("d",Date(),DateSerial(Year(Date()),Month([DOB]),Day([DOB]))))) Between 0 And 30));
    Cheers,

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Print next 8 days & info
    By skippernick in forum Reports
    Replies: 2
    Last Post: 04-06-2010, 12:38 PM
  2. calculate no. of working days
    By JOSE LUIS in forum Access
    Replies: 1
    Last Post: 02-01-2010, 03:55 PM
  3. Travel days.
    By emccalment in forum Access
    Replies: 1
    Last Post: 01-06-2010, 05:39 PM
  4. less than 180 days old
    By techexpressinc in forum Queries
    Replies: 2
    Last Post: 06-04-2009, 04:29 PM
  5. Total no of days in a month
    By wasim_sono in forum Forms
    Replies: 4
    Last Post: 10-15-2006, 01:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums