A Gentle Introduction to

SQL

DATES

How to work with dates; adding, subtracting and formatting.


Group by day of the week (using arithmetic)
We can use modular arithmetic to calculate the day of the week.
We happen to know that 20 May 1962 was a Sunday. We calculate the number of days from that day and take mod 7 value. This tells us the day of the week: 0 is Sunday, 1 is Monday...
access variations:
None

access
db2
mysql
oracle
postgres
sqlserver