Example #1
0
        //public static DateTime MONTHLY_RUN_ID = DateTime.Now.Date.Month;

        static DateTimeUtils()
        {
            var now = DateTime.Now.Date;

            FirstDayofThisMonth = now.AddDays(now.Day * -1 + 1);

            LastDayofThisMonth = FirstDayofThisMonth.AddMonths(1).AddDays(-1);

            FirstDayofLastMonth = FirstDayofThisMonth.AddMonths(-1);

            LastDayofLastMonth = FirstDayofThisMonth.AddDays(-1);

            FirstDayofThisWeek = now.AddDays(Convert.ToInt32(now.DayOfWeek.ToString("d")) * -1);

            FirstDayofLastWeek = FirstDayofThisWeek.AddDays(-7);

            LastDayofThisWeek = FirstDayofThisWeek.AddDays(6);

            LastDayofLastWeek = FirstDayofThisWeek.AddDays(-1);
        }
        static DateTimeUtils()
        {
            var now = DateTime.Now.Date;

            FirstDayofThisMonth = now.AddDays(now.Day * -1 + 1);

            LastDayofThisMonth = FirstDayofThisMonth.AddMonths(1).AddDays(-1);

            FirstDayofLastMonth = FirstDayofThisMonth.AddMonths(-1);

            LastDayofLastMonth = FirstDayofThisMonth.AddDays(-1);

            FirstDayofThisWeek = now.AddDays(Convert.ToInt32(now.DayOfWeek.ToString("d")) * -1);

            FirstDayofLastWeek = FirstDayofThisWeek.AddDays(-7);

            LastDayofThisWeek = FirstDayofThisWeek.AddDays(6);

            LastDayofLastWeek = FirstDayofThisWeek.AddDays(-1);

            TODAY_RUN_ID   = DateTime.Now.ToString("yyyy-MM-dd");
            MONTHLY_RUN_ID = FirstDayofThisMonth.ToString("yyyy-MM");
            MONDAY_RUN_ID  = FirstDayofThisWeek.ToString("yyyy-MM-dd");
        }