How do I extract the year from a date?

Discussions about CSEntry
Post Reply
uri
Posts: 15
Joined: December 11th, 2012, 11:52 pm

How do I extract the year from a date?

Post 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.
Gregory Martin
Posts: 1792
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

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

Post 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);
uri
Posts: 15
Joined: December 11th, 2012, 11:52 pm

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

Post by uri »

Thanks Gregory!
Post Reply