1. Learn
  2. /
  3. Courses
  4. /
  5. Exploratory Data Analysis in SQL

Connected

Exercise

Date arithmetic

You can subtract dates or timestamps from each other.

You can add time to dates or timestamps using intervals. An interval is specified with a number of units and the name of a datetime field. For example:

  • '3 days'::interval
  • '6 months'::interval
  • '1 month 2 years'::interval
  • '1 hour 30 minutes'::interval

Practice date arithmetic with the Evanston 311 data and now().

Instructions 1/4

undefined XP
  • 1
    • Subtract the minimum date_created from the maximum date_created.
  • 2
    • Using now(), find out how old the most recent evanston311 request was created.
  • 3
    • Add 100 days to the current timestamp.
  • 4
    • Select the current timestamp and the current timestamp plus 5 minutes.