I'm new to Access so please be kind...I'm trying to determine oldest and youngest employee, I'm sure that the line below is copied verbatim, any ideas I would be most grateful, and so would my shrink.
Thank you
Oldest:Max (DateDiff('m', Date)/12) Youngest:Min (DateDiff('m',Date)/12)
2 4100
[code]
SELECT distinct (SELECT fullname from tbltest a where date2 = (select Max([date2]) from tbltest)) AS oldest, (SELECT fullname from tbltest a where date2 = (select Min([date2]) from tbltest)) AS youngest
FROM tbltest;
[/code/]
I'm new to Access so please be kind...I'm trying to determine oldest and youngest employee, I'm sure that the line below is copied verbatim, any ideas I would be most grateful, and so would my shrink.
Thank you
Oldest:Max (DateDiff('m', Date)/12) Youngest:Min (DateDiff('m',Date)/12)
Here is your answer from a code perspective. I'm sure the dreaded 'SQL Gang' led by Mary and NeoPa will soon come on the scene and have a more practical answer. I'm just happening to experience a SQL meltdown, sorry: - Dim dteYoungestEmployee As Date
-
Dim dteOldestEmployee As Date
-
-
dteYoungestEmployee = DLookup("Max([BirthDate])", "tblEmployee")
-
dteOldestEmployee = DLookup("Min([BirthDate])", "tblEmployee")
-
-
Debug.Print "The youngest Employee was born on " & dteYoungestEmployee & _
-
" and is " & DateDiff("yyyy", dteYoungestEmployee, Now()) & _
-
" years old."
-
-
Debug.Print "The oldest Employee was born on " & dteOldestEmployee & _
-
" and is " & DateDiff("yyyy", dteOldestEmployee, Now()) & _
-
" years old."
OUTPUT: - The youngest Employee was born on 1/6/1992 and is 15 years old.
-
The oldest Employee was born on 6/1/1942 and is 65 years old.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Scott Knapp |
last post by:
Good Day -
I have a form which sets the current date, as follows:
<script type="text/javascript">
xx=new Date()
dd=xx.getDate()
mm=xx.getMonth()+1
yy=xx.getYear()
mmddyy=mm+"/"+dd+"/"+yy...
|
by: Dennis M. Marks |
last post by:
What is the maximum valid date range for the date(yyyy,mm,dd) function.
--
Dennis M. Marks
http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net
-----= Posted via...
|
by: Matteo |
last post by:
Hy everybody.
I'm not a html writer, but a sysadmin who's trying to help a user able
to compile an online form with IE but not with Mozilla (Moz1.6, Ns7.1,
Firefox 0.8+) due to a javascript date...
|
by: AdityaK |
last post by:
Is there anyway I can get weekend date for a given date using DB2
query? I couldn't find any DB2 function that can be used to do so.
Thanks,
Aditya
|
by: Matt |
last post by:
Given a date, how to find the beginning date and ending date of that week
please advise!
|
by: abcabcabc |
last post by:
I write an application which can let user define own date format to input,
How to convert the date string to date value with end-user defined date
format?
Example, User Defined Date Format as...
|
by: shyam vashista |
last post by:
i have problem in validation check for system date with server date
problem:::
If i change my system date as september 30, 2006
and use validation for filling form as current date as oct30,...
|
by: CheezIt2831 |
last post by:
hello, I have 5 tables(Alpha, Bravo, Charlie, Service, Trans). What i am trying to do is be able to select a start date and ending date for a report and include fields from the 5 tables. this is my...
|
by: IsdWeb |
last post by:
Hello,
I am a newbie to coding and need some help. I am trying to figure out
why the following code is not producing the correct Julian date. Any
suggestions? Also, I am trying to understand...
|
by: anagai |
last post by:
I just want to check if a date entered in a textbox is equal to the
current system date. I set the date object from the input field like
this:
dt1=new Date('10/01/2007');
the current system...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |