CIS 2640 Excel 07 - Dates and Date Functions

You might also like

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

ECH 07: Dates and date

Functions
Book: Microsoft Excel 2016 Data Analysis and Business Modeling
Internal Representation of a date

 Excel stores dates and times as a number representing the number of days since January
1, 1900 (and a fractional portion of a 24 hour day). This is called the serial format of
date or serial date-time.
 dddddd.tttttt
 The integer portion is number of days since 1/1/1900.
 The fractional portion is the fractional portion of a 24 hour day. For example, 8:00
a.m. is stored as 0.333333 (or 8 / 24)
 Tips
 To see the serial number behind a date: Ctrl + `
 You can also see the serial number by formatting a cell into General.
 Use datevalue() function to convert a string date to serial date.
 To convert a date to its serial number: Ctrl + Shift + ~
Dr. K. Chen, 2015 2
Watch out with the shorthand notation

 When you enter a date with only two digits in the year, you need
to be a bit more careful:
 Excel uses 29/30 as the cut-off point between 1900 and 2000.
 If year is 1 – 29, it is treated as a year in 2000.
 E.g., 1/1/29 = 1/1/2029, 1/1/00 = 1/1/2000
 If year is 30 – 99, it is treated as a year in 1900.
 E.g., 1/1/30 = 1/1/1930, 1/1/55 = 1/1/1955
 Tips
 The 29/30 cut-off started in Excel 97 and Excel 2000. Excel95 uses 19/20.
 When in doubt, use the full 4-digit year.
Dr. K. Chen, 2015 3
Two Items

 How do decipher date/time representation in A1?


 47119 is number of days since 1/1/1900.
 .2708333 is the time portion.
This is (6:30 a.m. / 24 hrs) = (6 * 60 + 30 minutes / 24 * 60
minutes) = 390 minutes / 1440 minutes = .2708333

 A7 shows that there were 366 days in 1900.


 Excel thinks 1900 is a leap year (with the date 2/29/1900), but in
fact 1900 was NOT a leap year. Watch out for this “bug”.

Dr. K. Chen, 2015 4


Exercise – Various date and time functions
 File: Dates.xlsx
 Functions to learn: year(), month(), day(), weekday(),
date(), datevalue(), workday(), workday.intl(),
networkdays() and networkdays.intl().

Dr. K. Chen, 2015 5


Exercise – The DateDiff function

 Syntax: datedif(start_date, end_date, interval)


 The function returns the difference between two date values
based on the interval specified.
 The interval of time can be any value in the table:
 Example
 =DATEDIF("1/1/2011", “8/1/2012", "y")  1
 =DATEDIF("1/1/2011", “8/1/2012", "d")  578
 =DATEDIF(a1, today(), “y”)

Dr. K. Chen, 2015 6

You might also like