Page 1 of 1

How do I extract the year from a date?

Posted: June 6th, 2013, 11:34 am
by uri
Hi,

I'm trying to build a deidentified ID from pieces of first and last names plus the year of birth. Is there a function that will extract part of a date, in particular the year?

Thanks.

Re: How do I extract the year from a date?

Posted: June 6th, 2013, 6:13 pm
by Gregory Martin
It all depends on how your date is stored. You may just have to do some algebra. For example, if your date is stored in YYYYMMDD numeric format, you could get the year by writing:
YEAR = int(DATE / 10000);

Re: How do I extract the year from a date?

Posted: June 8th, 2013, 4:09 pm
by uri
Thanks Gregory!