DAY() returns the day portion of a specified DateTime as a number.
Use DAY() to isolate the day portion of a DateTime.
DAY(D)
DAY() returns a numeric value denoting the day portion of a DateTime.
If the DateTime is purely a time or is invalid/blank, then DAY() returns a zero value.
Valid dates are in the range January 2, 1900 to December 31, 9999.
Using a date of August 14, 2012:
DAY(‘20120814‘) = 14