Friday, November 25, 2011

Get Date Difference in months from C#.NET


/// Returns the number of months between startDate and endDate.
/// If the startDate is greater than endDate the result is negative.
///
/// Start Date
/// End Date
///
        public int MonthDifference(DateTime startDate, DateTime endDate)
        {
            #region Analysis
            // This came from the following analysis
            // Assume 1 is start date and 2 is end date
            // if Y2 = Y1 then M2 - M1
            // else (12 - M1) + [(Y2 - Y1 - 1) * 12] + M2
            #endregion

            return endDate.Month - startDate.Month + ((endDate.Year - startDate.Year) * 12);
        }

Populate people picker field with logged in user in SharePoint using JS

Please use below code to populate people picker in SharePoint online, <script src="https://ajax.googleapis.com/ajax/libs/jquery/3....