Results 1 to 4 of 4
  1. #1
    weeblesue is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    Houston, TX
    Posts
    14

    Question Mixed dates - show only complete dates?

    I have imported an external file into Access 2007. There is a date column that contains different formatted dates. Some are year only, some are MMM-YY, and some are complete DD-MMM-YY. I would like to run a query that isolates only those that are complete, meaning have a date and month.

    example data;
    1524
    1826
    JAN-1844
    MAR-1987
    10-APR-1745


    12-NOV-1865

    Access has recognized the column as a Text column. If i try to import it as a Date column, there are many, many errors.

    However, it is not recognizing the 'year only' entries as years. If I try
    CDate([datecol]) on those first 2 rows, the results are:
    1099 ---- 1/3/1903
    1826 ---- 12/30/1904

    Where there is a month and date, Access presumes it's the first of the month, so these entries come out acceptably:
    JAN-1844 ---- 1/1/1844
    MAR-1987 ----3/1/1987

    And of course it's recognizing the full dates as their full correct date (even those from 1400's or 1600's).

    I have tried YearX: Year([datecol]),
    iif(isnull(month([datecol])),"Yes","No"), and this comes out right (yes's and no's are correct) but when i try to filter as = "Yes", i get "data type mismatch" error!
    I've tried coverting the date to Value (Val([datecol]) but had no luck there either.

    Any suggestions?

    thanks
    Susan

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    you can run following query for those have only year:
    select CDate([datecol]+"-1-1") from table1 where len(trim([datecol]))=4

  3. #3
    weeblesue is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    Houston, TX
    Posts
    14
    Thanks - but i am trying to exclude those from the query.

    But that does give me an idea - use the length of the text string to determine if the date is 'full' or not!

    Actually, that works well! If the length of the string is 10 or 11, the date is 'complete'. I can get what i want.

    thanks!
    Susan

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    You are welcome Susan.
    Last edited by weekend00; 10-28-2010 at 08:24 AM.

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

Similar Threads

  1. Dates
    By spqr in forum Queries
    Replies: 4
    Last Post: 09-28-2010, 02:33 PM
  2. Calendar to and From Dates
    By bobfin in forum Reports
    Replies: 10
    Last Post: 08-05-2010, 07:05 PM
  3. Between dates using Iif
    By unique in forum Access
    Replies: 1
    Last Post: 01-04-2010, 07:17 AM
  4. Need report to show dates
    By Brian62 in forum Reports
    Replies: 2
    Last Post: 11-20-2009, 12:05 PM
  5. Due dates
    By Mehbastan in forum Queries
    Replies: 5
    Last Post: 08-14-2009, 08:37 AM

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