Lecture 8 Lookup and Date-Time Functions

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 24

Lecture 8

Topic 8: Lookup &


Date/Time Functions
Lecture Overview
• Lookup functions
• How to enter date/time values
• Date/Time functions
• Manipulating date/time values
Date/Time Functions
How to Enter Date Values
• Excel recognizes valid date formats
only.
• Valid date formats include:
mm/dd/yyyy
i. 11/6/05 
ii. 6-Nov-05
iii. 6-Nov
Date Functions

1. The TODAY() Function


• Returns today’s (current) date.
• Example:
=TODAY()
2. DAY( ) Function
• returns a number, 1 to 31, representing a
day.
• Example:
A1=2/26/2021
=DAY(A1)26
3. MONTH( )
• returns a number, 1 to 12, representing a
month.
• Example:
A1=2/26/2021
=MONTH(A1)
4. YEAR()
• returns a number representing the year
(1900 to 9999).
• Example:
A1=2/26/2021
=YEAR(A1)
5. NETWORKDAYS() Function
• Counts the number of working days between
two dates, excluding weekends and holidays.
• Format:
=NETWORKDAYS(startdate,enddate,holidayrange)
• Example :
=NETWORKDAYS(A15,B15,A2:A11)
6. WORKDAY() Function
• gives an offset work day given the start date,
duration(number of days) and holidays.
• Format:
=WORKDAY(startDate,duration,HolidayRange)
• Example:
=WORKDAY(1/4/2008,10)
7. WEEKDAY ()
• returns an integer between 1 and 7 that
corresponds to the day of the week.
• E.g Sun 1,Mon 2…………Sat7
• Format:
=WEEKDAY(date)
Example:
A1=7/10/2021
=WEEKDAY(A1)
Entering Time Values
Excel recognizes valid time formats only.
Examples:
1. 24-Hour System:
21:41 21:41:35
2. 12-Hour System:
9:41 AM 9:41:35 PM
N/B There must be a space before AM/PM
Time Functions
1. NOW()
• Returns the current time.
• Example:
=NOW()
2. MINUTE() Function
Manipulating Date Values
• Date and time values can be manipulated
arithmetically.
• Example:
A1=7/10/2021
=A1+1 
=A1-2 
• Example:
=TODAY() + 1
Manipulating Date values using MAX( ) and
MIN( ) Functions
• Example:
1. =MIN(A1:A6)
2. =MAX(A1:A6)
Lookup Functions

• Used to locate and retrieve details from a


long list or table.
• There are 2 lookup functions :
i. VLOOKUP( ) and
ii. HLOOKUP( )
1. VLOOKUP( ) : Vertical Lookup Function
• works by scanning the values in a single
column from top to bottom (vertically).
• Once it finds the target, it then retrieves
other information along the same row.
• Format:
=VLOOKUP(searchKey, tableRange,
columnIndex,matchType)
• searchKey – the value to searched for.
• tableRange - the range within which to
conduct the search.
• columnIndex – the column number
whose value is to be retrieved.
• matchType – either Exact or
Approximate match.
1/TRUE – Approximate match (default)
0/FALSE – Exact match
• Examples:
=VLOOKUP(B3, D3:F8,3)  Approximate
=VLOOKUP(B3, D3:F8,3,0)  Exact
Exact
=VLOOKUP(B3, D3:F8,3,FALSE) 
Approximate
=VLOOKUP(B3, D3:F8,3,TRUE) 
Approximate
=VLOOKUP(B3, D3:F8,3,1) 
Lookup Functions Cont’d
2. HLOOKUP( ) : Horizontal Lookup
Function
• works by scanning the values in a single
row from left to right.
• Once it finds the target, it then retrieves
other information along the same
column.
Lookup Functions Cont’d
• Format:
=HLOOKUP(searchKey, tableRange,
rowIndex,searchType)
Lab
1. Write a function/formula to determine: a) today’s date. B).
2 days ago date.
2. Write a function/formula to determine the number of
working days in the month of October. Note it has 2
holidays: Moi day (10/10/2012) and Kenyatta
day(20/10/2012).
3. The southern bypass project commenced yesterday
(16/3/2012) and it is scheduled to take 720 days. Write
function to determine the date it will be completed.
4. Write function/formula to determine the number of days
between 13/2/2000 and 28/12/2012.

You might also like