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
What area unit the various kinds of info compression introduced in sql server 2008?
What is the distinction amongst delete and truncate?
Describe in brief system database.
What do you mean by table and field in sql?
How do I repair damaged sql server mdf file database? In previous day my mdf file has got damage due to unknown reasons then I used dbcc chekcdb command but it failed, MDF file is important for me, I don’ know that how to get back mdf file data. Please anyone suggest me?
What is catalog views?
How to handle error or exception in sql?
What are logical database components? : SQL Server Architecture
What are the restrictions that views have to follow? : SQL Server Architecture
Name 3 ways to get an accurate count of the number of records in a table?
Explain different types of locks in sql server.
What stored procedure would you use to view lock information?
Explain the phases a transaction has to undergo?
Why I am getting "the microsoft .net framework 2.0 in not installed" message?
How real and float literal values are rounded?