Results 1 to 10 of 10
  1. #1
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171

    More date processing issues

    Table defines date of birth [DOB] as 'Short Date', I have also tried defining it as m/d/yyyy. Query selecting birthdays in next 30 days. In the query I have a calculated field as follows Birthday: DateSerial(Year(Date()),Month([DOB]),Day([DOB])) and in the criteria I have Between Date() And DateAdd("d",30,Date()). When requesting datasheet view a message 'Data type mismatch in criteria expression' appears.



    I'm baffled! Any thoughts?

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    Don't see anything wrong. Described scene duplicated in attached and works OK.


  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    dates are stored as numbers - what you see as a date is just a format of that number so ' I have also tried defining it as m/d/yyyy' is irrelevant. What is more likely is that your DOB field is not specified as a date type.

  4. #4
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    The table I am working with is imported from Excel. There are 5 date fields in the spreadsheet. Three of them give me no problems, two have this issue. In the spreadsheet all dates are formatted as m/d/yyyy. It is imported to create a new table. This table after import defines the fields as Date/Time with a format of m/d/yyyy. In an append query I manipulate some of the fields, change names and eliminated some of the fields. This table I created with all dates defined as Date/Time and format m/d/yyyy.

    Does this offer any clues?
    Thanks

  5. #5
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    Maybe you could use the IsDate function to help track the problem down.
    IsDate returns True if the expression is a date or is recognizable as a valid date; otherwise, it returns False

  6. #6
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    Don't apply a format to date time fields in tables. Access stores them correctly internally. Formatting dates should only be done for display purposes on forms.
    Applying a format will only confuse the issue. If you want to ensure a date use CDate()
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    Perhaps there is an issue with the data - check all dates are imported correctly - excel has a habit of hiding data type issues

  8. #8
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    Thanks for the suggestions. The IsDate returns a -1 for all date fields which I assume is True.
    Any other ideas.

  9. #9
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    Any other ideas.
    Did you look at post #2? It works.
    You could import your table into that database and improvise the same solution for troubleshooting?

  10. #10
    WAVP375 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    Problem solved. I changed direcrions a little. I chose to look at next month instead of next 30 days.
    Thanks for your ideas they have made me aware of new possibilities for solutions to future problems.

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

Similar Threads

  1. Date issues on equpment sent out
    By Shredder in forum Access
    Replies: 2
    Last Post: 05-23-2018, 03:15 PM
  2. VBA Sql date issues
    By Larryg in forum Queries
    Replies: 7
    Last Post: 04-02-2017, 02:29 PM
  3. Date Range form issues
    By msuguy71 in forum Forms
    Replies: 1
    Last Post: 12-31-2013, 03:32 AM
  4. Date format issues
    By budedwards in forum Queries
    Replies: 14
    Last Post: 03-15-2012, 10:52 AM
  5. Date expression issues
    By QTip in forum Queries
    Replies: 4
    Last Post: 01-06-2011, 03:43 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