Wednesday, September 4, 2013

How to get first and last day of month asp net c#

First day of month
    public static DateTime GetFirstDayOfMonth(DateTime dt)
    {
        return new DateTime(dt.Year, dt.Month, 1);
    }
Last day of month
    public static DateTime GetLastDayOfMonth(DateTime dt)
    {
        return new DateTime(dt.Year, dt.Month, 1).AddMonths(1).AddDays(-1);
    }

No comments:

Post a Comment