...

View Full Version : Year()



NancyJ
08-19-2005, 12:23 PM
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

SpirtOfGrandeur
08-19-2005, 02:00 PM
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.

ghell
08-20-2005, 11:06 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum