Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# year problem

Posted on 2004-04-02
Medium Priority
216 Views
I what to use a 2 digit year and I want to beable to convert if you enter 04 it knows it is 2004 and if you put in 99 for 1999 it know how to convert it. can anyone help me on this?
0
Question by:cdb424ttm
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3

LVL 10

Accepted Solution

Kavar earned 2000 total points
ID: 10741427

use this function

Function GetYear(whatYear as integer) as integer
if WhatYear<31 then
GetYear=WhatYear+2000
else
GetYear=WhatYear+1900
end if
End Function
0

LVL 10

Expert Comment

ID: 10741444
or in c

int GetYear(in WhatYear)
{
if (WhatYear<31)
{
return WhatYear+2000;
}
else
{
return WhatYear+1900;
}
}
0

Author Comment

ID: 10741494
what is testing it for less then 31 do?
0

LVL 10

Expert Comment

ID: 10741515
because you have to set a threshold somewhere and say, if this date or later, they mean 19xx and this date or sooner and they mean 20xx, I picked 31 (its pretty much an industry standard)
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Six Sigma Control Plans
Starting up a Project
###### Suggested Courses
Course of the Month10 days, 22 hours left to enroll