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

Microsoft

Office Excel
Date & Time Functions
To enter a date in Excel, use the "/" or "-" characters. To enter a time, use the ":"
(colon). You can also enter a date and a time in one cell.
Year, Month, Day
To get the year of a date, use the YEAR function.
Date Function
1. To add a number of days to a date, use the following simple formula.
Date Function
2. To add 4 years, 2 months and 9 days, use the DATE function.
Current Date & Time
To get the current date and time, use the NOW function.
Hour, Minute and Second
To get the current date and time, use the NOW function.
Time Function
To add a 2 hours, 10 minutes and 70 seconds, use the TIME function.
Text Functions
Join Strings use the & operator.
Age Calculation
The DATEDIF function in Excel is used to figure out a person's age. It is a built-
in, easy-to-use function that takes the person's date of birth as an input and gives
back the person's age as output.

The syntax of the DATEDIF function is defined as below:


Age Calculation
=DATEDIF(Birth_Date,Specific_Date,"Y")
YEARFRAC Function
YEARFRAC function is another useful way to figure out the age in Excel. It is
easy to use and is often used to figure out how old someone is in years. It lets us
find out how old we are from a given birthdate up to a certain date.

The syntax to calculate the age of a person using the YEARFRAC function is
defined as below:
YEARFRAC Function
Formula: =INT(YEARFRAC(B2,TODAY()))
Calculating Age in Months
From the previous formula for DATEDIF change the unit from “Y” to “M” in the
formula.

=DATEDIF(B2,TODAY(),"M")
Calculating Age in Years, Months, and Days
=DATEDIF(B2,TODAY(),"Y") & " Years, " & DATEDIF(B2,TODAY(),"YM")
& " Months, " & DATEDIF(B2,TODAY(),"MD") & " Days"
Text Functions
To extract the leftmost characters from a string, use the LEFT function. The 2 is
the number of letter to be display
Text Functions
To extract the rightmost characters from a string, use the RIGHT function.
Text Functions
To extract a substring, starting in the middle of a string, use the MID function.
Started at position 3 (p) with length 2.
Text Functions
To get the length of a string, use the LEN function.
Text Functions
To replace existing text with new text in a string, use the SUBSTITUTE function.
VLOOKUP
1. Insert the VLOOKUP function shown below.
VLOOKUP

Explanation: the VLOOKUP function looks for the ID (104) in the leftmost
column of the range $D$4:$F$7 and returns the value in the same row from the
third column (third argument is set to 3). The fourth argument is set to 0 (FALSE)
to return an exact match or a #N/A error if not found.

Formula used: =VLOOKUP(A2,$D$4:$F$7,3,0)


VLOOKUP

2. Drag the VLOOKUP function in cell B2


down to cell B11.

Note: when we drag the VLOOKUP function


down, the absolute reference ($D$4:$F$7)
stays the same, while the relative reference
(A2) changes to A3, A4, A5, etc.
HLOOKUP
In a similar way, you can use the HLOOKUP (Horizontal lookup) function.
Formula: =HLOOKUP(A2,$E$3:$H$5,3,0)
HLOOKUP
Output

You might also like