CSharp examples for System:DateTime Day
Gets the start and end dates for "last 3 days" date-range, relative to a specified date.
// Copyright (c) .NET Foundation. All rights reserved. using System.Windows.Forms; using OpenLiveWriter.Interop.Windows; using System.Runtime.InteropServices; using System.Globalization; using System.Diagnostics; using System;// w w w .j a v a 2 s. c om public class Main{ /// <summary> /// Gets the start and end dates for "last 3 days" date-range, relative to a specified date. /// </summary> /// <param name="dateTime">The DateTime that the calculation is relative to.</param> /// <param name="start">Start date.</param> /// <param name="end">End date.</param> public static void GetLast3DaysDateRange(DateTime dateTime, out DateTime start, out DateTime end) { end = dateTime.Date; start = end.AddDays(-2); } }