Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Does the order of columns in update statements matter?

906


What is log ldf?

962


How to list all stored procedures in the current database using ms sql server?

1111


What is the importance of concurrency control?

1211


Does index slows down insert statements?

984


What is store procedure? How do they work?

985


What is side by side migration in sql server?

1078


What do you understand by user-defined function in the sql server?

935


What is the difference between createstatement and preparedstatement?

921


between cast and convert which function would you prefer and why?

941


How do you rename a table in sql server?

1002


How to use transact-sql statements to access the database engine?

1042


How to trouble shoot if unable to connect SQL Server

1973


What is co-related sub query?

1007


Is it important for a database administrator to understand the operating system and file access?

965