Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Year()

  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts

    Year()

    year(04/99) = 1999
    year(04/00) = 2000
    year(04/01) = 2005 ?
    Why is that?
    I'm checking expiration dates of credit cards but when the year is greater than 2000 then it always says the year is 2005, any year from 01-31 outputs the year as 2005, 00 is 2000 and any other 2 digit number is 19xx
    Last edited by NancyJ; 08-19-2005 at 01:40 PM.

  • #2
    Regular Coder
    Join Date
    May 2005
    Location
    Michigan, USA
    Posts
    566
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by NancyJ
    year(04/99) = 1999
    year(04/00) = 2000
    year(04/01) = 2005 ?
    Why is that?
    I'm checking expiration dates of credit cards but when the year is greater than 2000 then it always says the year is 2005, any year from 01-31 outputs the year as 2005, 00 is 2000 and any other 2 digit number is 19xx
    You have just gotten used to the computer handling logic for you.

    04/99 is April 1 1999
    04/00 is April 1 2000
    04/01 is April 1 Current Year.

    The first two are years because they are invalid days. So the function tries to change them to years and finds a valid date and runs it as such. You need to seperate them out.
    Note: I do not test code. I just write it off the top of my head. There might be bugs in it! But if any thing I gave you the overall theory of what you need to accomplish. Also there are plenty of other ways to accomplish this same thing. I just gave one example of it. Other ways might be faster and more efficient.

  • #3
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    extend the date and use CStr() and maby CDate()

    / is the devision operator so that might mess with it a bit, year expects a date int, string or date really

    eg: Year("01/04/01") --> 2001


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •