### Math Forum - Ask Dr. Math

To add or subtract values from date/time variables: Select Calculate with dates and times on the introduction screen of the Date and Time Wizard. Select Type of . Date: Dividing It Up. Division is a quick and easy way to subtract the same number several times. 27 ÷ 9 = 3 This is the same as subtracting 9 from 27 three times. THE FIX: Although dates show up everywhere in databases, it can be the base date (12/30/), with negative numbers representing days before that date; you can simply add them—and if you subtract two dates that have the same time, .

Time object represents a precise moment of time in a day. It doesn't say anything about the day of the week, or the year, though. It's accurate to a nanosecond.

### Add or Subtract Values from Date/Time Variables

Date object represents just a date: It's accurate to, well, a day. DateTime object is a combination of a date and a time of day, and so it specifies an exact moment in time.

It's accurate to a millisecond or so. Use one of these constructors to make the type of object you want: Date ,3,15 a Dates. DateTime ,11,11,11,11,11 a Dates. Sometimes you want UTC the reference time for the world, without local adjustments for daylight savings: For both date and datetime objects, you can obtain the year, month, day, and so on: The last function, dayofweekofmonth birthday day of week of monthtells us that the 15th of March,was the third Saturday of the month.

## 3 Ways to Add or Subtract Days to a Date

You can also find days relative to a date, such as the first day of the week containing that day, using the adjusting functions, described below. Subtracting two dates or datetimes to find the difference is the most obvious one: Milliseconds or some other unit: Year 20 defines a period of 20 years, and Dates.

Month 6 defines a period of 6 months. So, to add 20 years and 6 months to the birthday date: Month 6 Here's 6 months ago from now: Year 2 - Dates. Here's the date and time for two weeks and 12 hours from now: To retrieve the value as a number, use the function Dates.

To find out which of these fall on weekdays, you can provide an anonymous function to filter that tests the day name against the given day names: Date "" 1 Jan 31 Jan 2 Mar 1 Apr 1 May 31 May 30 Jun 30 Jul 29 Aug 28 Sep 28 Oct 27 Nov 27 Dec Date formatting[ edit ] To specify date formats, you use date formatting codes in a formatting string.

For example, you create a DateTime object from a string by identifying the different elements in the incoming string: DateTime "Fri, 15 Jun In the second example, the formatting characters matched up as follows: Fri, 15 Jun S You can supply a format string to Dates.

This is appropriate not only because the sum of two positive numbers is greater than either, but because it was common for the ancient Greeks and Romans to add upward, contrary to the modern practice of adding downward, so that a sum was literally higher than the addends.

The later Middle English terms "adden" and "adding" were popularized by Chaucer. Even for the simple case of adding natural numbersthere are many possible interpretations and even more visual representations. Combining sets[ edit ] Possibly the most fundamental interpretation of addition lies in combining sets: When two or more disjoint collections are combined into a single collection, the number of objects in the single collection is the sum of the number of objects in the original collections.

This interpretation is easy to visualize, with little danger of ambiguity. It is also useful in higher mathematics; for the rigorous definition it inspires, see Natural numbers below. However, it is not obvious how one should extend this version of addition to include fractional numbers or negative numbers. A translation by 2 followed by a translation by 4 is the same as a translation by 6. A translation by 4 is equivalent to four translations by 1.

## Add or Subtract Values from Date/Time Variables

A second interpretation of addition comes from extending an initial length by a given length: When an original length is extended by a given amount, the final length is the sum of the original length and the length of the extension. The unary view is also useful when discussing subtractionbecause each unary addition operation has an inverse unary subtraction operation, and vice versa.

**Subtracting Numbers in a different base**

The fact that addition is commutative is known as the "commutative law of addition". Some other binary operations are commutative, such as multiplication, but many others are not, such as subtraction and division.

That addition is associative tells us that the choice of definition is irrelevant.