-
Book Overview & Buying
-
Table Of Contents
Data Analysis Using SQL and Excel - Second Edition
By :
Perhaps the most natural relationship between two dates is the duration between them. This section looks at differences between dates in different time units: days, months, years, and by the number of specific days of the week. Surprisingly, investigating durations at each of these levels produces interesting results.
The BillDate and ShipDate columns provide a good place to start the investigation, particularly in conjunction with the OrderDate column in Orders. Two natural questions are: How long after the order is placed are items shipped? How long after the order is placed are items billed?
These questions are about durations. In most dialects of SQL, simply subtracting one date from the other calculates the duration between them in days (and this works for the DATETIME data type in SQL Server but not for the DATE data type). This also works in Excel, but Microsoft SQL uses the DATEDIFF() function for DATE and DATETIME.
The following calculates...
Change the font size
Change margin width
Change background colour