Join Bill Weinman for an in-depth discussion in this video Dates and times, part of SQL Essential Training (2014).
Dates and times have specific properties that are important to understand in database systems. They can be used for chronological and durational purposes, as well as for internal purposes within a system or application. Dates and times are typically represented in a standard format with the most significant parts to the left and and the least significant parts to the right. This format is sometimes referred to as SQL format. It lends itself well to database sorting and searching operations. Dates and times are usually represented internally as UTC.
UTC is technically equivalent to the Greenwich Mean Time or UT1 timezone. That is the current date and time, at Greenwich, England, without adjusting for summertime. UTC is sometimes associated with Reykjavik, Iceland because Reykjavik is always on UTC time and does not observe any seasonal time adjustments. This standardization allows unambiguous, relative date and time calculations across local and international boundaries. UTC is easily converted to and from local time zones for reporting and display purposes.
Most database systems have special types set aside for dates and times. These types are generally represented as packed integer or decimal values and are optimized for date and time calculations. Other database systems simply use text or Varchar types for dates and times. The conversion to and from text form is generally minimal. And, it's cost is mitigated by the fact that even when stored in a specific format, these conversions happen often enough that the number of conversions is not generally increased or decreased by storing the data one way or another.
Every database system has a set of functions specifically tasked for handling dates and times. These functions are not standardized, and each system has its own set. In the next lesson, I'll show you the date and time related functions for SQL Light, the system we are using for these exercises.
- Understanding SQL terminology and syntax
- Creating new tables and records
- Inserting and updating data
- Writing basic SQL queries
- Sorting and filtering
- Accessing related tables with JOIN
- Working with strings
- Finding the numeric type of a value
- Using aggregate functions and transactions
- Updating a table with triggers
- Creating views
Skill Level Beginner
Q: For Mac OS X: When I try to start the Apache Web Server from the XAMPP control panel, it doesn't start, and when I open "localhost" in my web browser, I see a white screen that says "It Works!" instead of the XAMPP page.
sudo apachectl stop
Q: I'm on a Mac, and I get an error in SID that says "attempt to write a read only database." How can I fix this?
A: This usually means that the database folder does not have sufficient permissions for writing by the web user. This can happen if you create the SQL folder new, rather than copying it from the Exercise Files. Here's how to fix this:
- Open a Finder window and Navigate to /Applications/XAMPP/htdocs/SQL
- Control-click on the SQL folder and select "Get Info" from the context menu.
- Under "Sharing and Permissions" (you may need to open the disclosure triangle), in the "everyone" row, select "Read & Write."Then you can close the Info window.
- Now repeat the process for the three *.db files inside the folder.