473,386 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Oldest:Max (DateDiff('m', Date)/12) Youngest:Min (DateDiff('m',Date)/12)

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)
May 5 '07 #1
2 4100
JConsulting
603 Expert 512MB
[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/]
May 6 '07 #2
ADezii
8,834 Expert 8TB
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:
Expand|Select|Wrap|Line Numbers
  1. Dim dteYoungestEmployee As Date
  2. Dim dteOldestEmployee As Date
  3.  
  4. dteYoungestEmployee = DLookup("Max([BirthDate])", "tblEmployee")
  5. dteOldestEmployee = DLookup("Min([BirthDate])", "tblEmployee")
  6.  
  7. Debug.Print "The youngest Employee was born on " & dteYoungestEmployee & _
  8.             " and is " & DateDiff("yyyy", dteYoungestEmployee, Now()) & _
  9.             " years old."
  10.  
  11. Debug.Print "The oldest Employee was born on " & dteOldestEmployee & _
  12.             " and is " & DateDiff("yyyy", dteOldestEmployee, Now()) & _
  13.             " years old."
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. The youngest Employee was born on 1/6/1992 and is 15 years old.
  2. The oldest Employee was born on 6/1/1942 and is 65 years old.
May 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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...
8
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...
4
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...
2
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
3
by: Matt | last post by:
Given a date, how to find the beginning date and ending date of that week please advise!
1
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...
1
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,...
7
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...
4
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...
4
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...
0
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,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...
0
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...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.