Results 1 to 5 of 5
  1. #1
    shztexn is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    8

    Convert General number to "correct" year date data type

    In a query I would like to extract the last ten years. This is what the data looks like:

    12/13 (Data type = text)

    (Short for 2012/2013 which actually represents 7/1/2012 to 6/30/2013.)

    I am able to extract the "12" and turn it into the general number 2012 using: ("20" & Left([TAXYR],2))*1

    But how can I convert that to the data type-date so I can include those records in the past ten years from todays date? I was trying to use DateAdd but I think the problem is the data type and where converting to date gives me "1905" or "9/##/1905." I get why it does that, but is there a workaround? Maybe adding 39,785 days?? (2014-1905)*365

    Thanks in advance.

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    YearStart: cdate("7/1/" & left([taxyr], 2))
    YearEnd: cdate("6/30/" & left([taxyr], 2) + 1)
    or
    YearEnd: cdate("6/30/" & right([taxyr], 2)

  3. #3
    AlexHedley's Avatar
    AlexHedley is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Apr 2013
    Location
    England
    Posts
    180

    Convert General number to "correct" year date data type

    You could also use the DateSerial function.
    Code:
    DateSerial(year, month, day)
    Here is a tip using it to calculate the last day of the month.
    http://www.599cd.com/tips/access/last-day-of-month/

    MS: http://office.microsoft.com/en-gb/ac...001228813.aspx

  4. #4
    shztexn is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    8
    Thank you, Alex. I will check that out. I was not aware of the function DateSerial!


    Quote Originally Posted by AlexHedley View Post
    You could also use the DateSerial function.
    Code:
    DateSerial(year, month, day)
    Here is a tip using it to calculate the last day of the month.
    http://www.599cd.com/tips/access/last-day-of-month/

    MS: http://office.microsoft.com/en-gb/ac...001228813.aspx

  5. #5
    shztexn is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    8
    Thank you, rpeare. I actually thought of that. I will investigate whether changing the date to a full date will help.

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

Similar Threads

  1. Replies: 3
    Last Post: 05-31-2013, 04:32 PM
  2. How to format a "Number" Data type
    By undee69 in forum Access
    Replies: 4
    Last Post: 12-16-2012, 10:20 PM
  3. Replies: 0
    Last Post: 01-11-2012, 12:34 PM
  4. Replies: 2
    Last Post: 05-17-2011, 02:40 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