Results 1 to 4 of 4
  1. #1
    comfygringo is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    12

    Birthdays


    I have a text field with birth dates. The field is formatted with only the month and the year. Sometimes only the year is available. I want to run a query that will return birth dates within today's month. My query looks like this:

    Code:
    SELECT Salutation.Salutation, Valid_Numbers.[First Name] & " " & [Last Name] AS Name, Valid_Numbers.[House Number] & " " & [Street Name] AS Address, Valid_Numbers.City, Valid_Numbers.ST, Valid_Numbers.ZIP, Valid_Numbers.[Date of Birth]
    FROM Salutation INNER JOIN Valid_Numbers ON Salutation.ID=Valid_Numbers.Salutation
    WHERE Len(Valid_Numbers.[Date of Birth])=7 And Switch(Left(valid_numbers.[house number],1)<>0,Left(Valid_Numbers.[Date of Birth],2)=Month(Date()),Left(valid_numbers.[house number],1)=0,Mid(Valid_Numbers.[Date of Birth],InStr(3,Valid_Numbers.[Date of Birth],"/")-1,1)=Month(Date()));

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    What is the issue? Does the query work? If not, why - error message, wrong results, nothing?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    comfygringo is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2013
    Posts
    12

    Birthdays

    Quote Originally Posted by June7 View Post
    What is the issue? Does the query work? If not, why - error message, wrong results, nothing?
    The query works, but it returns nothing.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The query is linking on ID and Salutation fields. Salutation has ID values?

    I can't make sense of the Switch expression. Basic syntax for Switch is:

    Switch(if this expression true, then return this, if this expression true, return this, ...)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Birthdays
    By bambi_ in forum Queries
    Replies: 1
    Last Post: 05-22-2012, 03:29 AM
  2. Help with SQL: Birthdays in Next 30 days
    By kaylachris in forum Queries
    Replies: 1
    Last Post: 06-21-2010, 05:24 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