How to Get Employee data whose age is going to be 40 by this weekend?

Reply
New Contributor
Posts: 3

How to Get Employee data whose age is going to be 40 by this weekend?

HI Everyone!!!!!!!!!!!!!!

I need your help!!!!!!!!!!!!!!!!!!

If i need to get employee details from Employee table whose age reach 40 this week or today by using SQL command.

ex:

id       name      dob

101     selva      20/09/1972

102  kumar      21/09/1972

103   rahul       23/09/1973

Thank you

Super User
Super User
Posts: 6,502

Re: How to Get Employee data whose age is going to be 40 by this weekend?

You can get the end of this week using this:

intnx('week',today(),0,'end')

SAS has a page published on calculating AGE.  http://support.sas.com/kb/24/808.html

If you combine them you get this:

floor((intck('month',DOB,intnx('week',today(),0,'end'))

- (day(intnx('week',today(),0,'end')) < day(DOB))) / 12)

Respected Advisor
Posts: 3,900

Re: How to Get Employee data whose age is going to be 40 by this weekend?

I believe for your very specific case below code should do (for weeks beginning on Sunday):

data have;

  format dob date9.;

  dob='26sep1972'd;

  ThisWeek_Birthday40_Flg=  NOT intck('week',(intnx('year',dob,40,'s')),date());

run;

Ask a Question
Discussion stats
  • 2 replies
  • 179 views
  • 1 like
  • 3 in conversation