we have emp table like Ename,EDOJ,EDOB with Column
structure.but we want to know the employee Age.How? Any
Body Plz

Answer Posted / rajesh k. gupta

Hi,
In order to answer your question I would like to put all
three possible answers as follows:-

1.If You want to find out the age of employee as on the
date of Joining (Field name EDOJ) then Query will be

select *,datediff(year,EDOB,EDOJ) as Eage from emp

2. If you want to find out the age of employees as on
current date, query will be as follows:-

select *,datediff(year,EDOB,getdate()) from emp

3. If you want to find out age as on specific date stored
and taken from other variable then query will be :-

You need to declare a variable as datetime then need to
tore its value to it.

declare @dtb datetime
set @dtb='1990/01/10'
select *,datediff(year,EDOB,@dtb) from emp
---------------------------------------
For any clarification Please feel free to contact me.
Rajesh
9342284359

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to Check if table exists in sql server?

615


How can you find out which stored procedures are recompiling?

510


What languages bi uses to achieve the goal?

507


What is a system database and what is a user database?

574


what stored procedure can you use to display the current processes? : Sql server administration

528






hi, the following are the outputs of sp_spaceused and sp_tempdbspace sp_spaceused ------------ database size unallocated size tempdb 77752.95 MB 28026.99 MB sp_tempdbspace ------------- database size spaceused tempdb 77752.945312 1.007812 the unused space in sp_spaceused is nearly 28 Gb and in sp_tempdbspace is nearly 76 Gb cany any one explain about this output and why its giving different results.

2462


What are the properties of primary key?

504


What are “unrepeatable reads”?

736


You want to check the syntax of a complicated update sql statement without executing it. What command should you use?

482


as a part of your job, what are the dbcc commands that you commonly use for database maintenance? : Sql server database administration

486


Is oracle faster than sql server?

549


Explain relational data?

540


How to set database to be single_user in ms sql server?

559


What command do we use to rename a database?

609


what is the difference between Tabular and Matrix report?

124