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',D ate)/12)
2 4123
[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/]
ADezii 8,834
Recognized Expert Expert
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',D ate)/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
document.write(mmddyy)
|
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 Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
|
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 check.
Let's go straight to the point:
<script language="JavaScript">
alert("Date: "+Date.parse("2000-01-01"))
|
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 "dd/MM/yyyy"
input as "01082003" convert to date value as, 01 Aug 2003
Example, User Defined Date Format as "yyyy,dd,MM"
|
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, 2006 than it will ask me for check ur entry date but wen i fill form that time date is oct 30, 2006
so how to solve this problem ? how to check date with server date?
it is not compulsary that system date by which i am filling form date is same...
|
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 code:
SELECT , , , ,
FROM
UNION SELECT , , , ,
FROM
UNION SELECT , , , ,
FROM
UNION SELECT , , , ,
FROM
|
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 the syntax liek what
does DateAdd mean? If anyone can offer some good tutorials it would
be appreciated as well.
Thanks in advance.
|
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 date is retrieved like this:
curDt = new Date();
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |