How would one keep a DOB field private from others if it is used to display the users age? For example, how is stackoverflow Birthday field kept private from other users? When is the display field Age changed? Is it changed just on the first of each month or randomly within an random range of Birthday? Or maybe just at the first of each year?
-
not programming related... but funny you should ask that, I have wondered the same thing. Scan SO once a day for a year and you can figure out the declared birthdays of the users. Some of them will be true. – cletus Jun 21 '09 at 14:50
-
That is why the "for example" was added. More of a design question – CW Holeman II Jun 21 '09 at 14:56
-
2The text in your profile is "never displayed, used to show age". It rolls over at the given date. Another question would be "why do we need an age field". – Toon Krijthe Jun 21 '09 at 14:57
-
I'm not sure I understand why it's so important to keep your DOB private here. If someone on StackOverflow wants to send me a card w/200 rep points on my b-day, that's ok with me. ;) – C-Pound Guru Jun 21 '09 at 15:14
-
C-Pound Guru, the reason you might not want make your date of birth public is identity theft. From http://www.privacyrights.org/fs/fs17-it.htm: "Using a variety of methods, criminals steal Social Security numbers, driver's licenses, credit card numbers, ATM cards, telephone calling cards, and other pieces of individuals' identities such as date of birth. They use this information to impersonate their victims, spending as much money as they can in as short a time as possible before moving on to someone else's name and identifying information." – Luke Girvin Jun 21 '09 at 15:29
-
Reposted to http://meta.stackexchange.com/questions/2282/how-is-stackoverflow-birthday-field-kept-private – CW Holeman II Jul 03 '09 at 22:28
2 Answers
I can't speak conclusively, but I know that the age in my SO profile rolled over, as expected, on my birthday. I suppose someone could scan the SO profiles daily and record the ages, then identify someone's birthday by when they change, but if someone wants to know that badly, I guess they can know. If you're really concerned about your privacy, don't put in your real birthday (or don't put one in at all).
Also, either intentionally or unintentionally, the user ages provided in the data dump aren't always accurate. I suspect that it's (current year)-(birth year), which leads to an age in the dump (22, in my case) that's 1 more than the user's actual age (I'm actually 21).

- 77,653
- 43
- 148
- 164
Surely the value is calculated everytime you visit the Profile page. It would be far too intensive to be calculating and storing everyone's age constantly.
Of course if you have a class of type Profile, you'd simply make it a readonly property!
Something like:
public static int CalculateAge(DateTime birthDate) {
DateTime today = DateTime.Today;
int personAge = (today.Year - userBirthDate.Year);
// deduct a year if the birthday hasn't passed yet.
if ((today.Month < birthDate.Month) || (today.Month == userBirthDate.Month && today.Day < userBirthDate.Day))
--personAge;
return personAge;
}
Edit: also famously asked in Question 9

- 1
- 1

- 98,673
- 67
- 256
- 322