Log in to see Cloud of Tags

Wealth-Lab Wiki

DaysBetweenDates

RSS

Syntax

public static int DaysBetweenDates( this int fromDate, int toDate ) public static int DaysBetweenDates( this string fromDate, string toDate )

public int DaysBetweenDates( int fromDate, int toDate ) public int DaysBetweenDates( string fromDate, string toDate )


Parameter Description

fromDateStarting date
toDateEnding date

Description

Determines the number of calendar days including weekends between the two specified dates, Date1 and Date2, in yyyyMMdd format (which you can easily reconfigure by following the standard Date and Time Format specifiers list.

Two formats are supported as overrides: both dates as integer values, or both dates as string values.

Example

Example using C# extension methods:

using System; using WealthLab;

public class DBDates: WealthScript { protected override void Execute() { string begDate = "20040112"; string endDate = "20080125"; int iBegDate = 20040112; int iEndDate = 20080125; PrintDebug( begDate.DaysBetweenDates( endDate ) ); PrintDebug( iBegDate.DaysBetweenDates( iEndDate ) ); } }


Legacy syntax example:

using System; using WealthLab; using Community.Components; // DaysBetweenDates here /*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/

public class DBDates: WealthScript { protected override void Execute() { // Create an instance of class that holds the method Calculate calc = new Calculate(this); // pass WealthScript as "this" string begDate = "20040112"; string endDate = "20080125"; int iBegDate = 20040112; int iEndDate = 20080125; PrintDebug( calc.DaysBetweenDates( begDate, endDate ) ); PrintDebug( calc.DaysBetweenDates( iBegDate, iEndDate ) ); } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.