Koen
Koen

Reputation: 3686

DateTime.AddDays(7) vs Calendar.AddWeeks(1)

Can both methods deliver different results under certain circumstances? Same question for negative values...

Upvotes: 1

Views: 315

Answers (2)

Straight from Reflector:

public DateTime AddDays(double value)
{
    return this.Add(value, 86400000);
}

public virtual DateTime AddWeeks(DateTime time, int weeks)
{
    return this.AddDays(time, weeks * 7);
}

Note, however, that AddWeeks is defined as virtual.

Upvotes: 2

Robert Levy
Robert Levy

Reputation: 29073

They always do the same thing. AddMonth and AddYears will vary but a week is always 7 days

Upvotes: 2

Related Questions