Is there away to do this in SQL Server Stored Procedure. I am basically trying to determine full datetime pay period base upon date time now for two weeks using the formula below. It works in code. But I need to do it in a query for a filter purpose. The payperiod variable is 14 days.
DateTime baseDate = Properties.Settings.Default.BaseDate; // new DateTime(2010, 12, 25); TimeSpan ts = DateTime.Today - baseDate; int numOfDaysDiff = ts.Days; int numOfBiWeeks = numOfDaysDiff / Properties.Settings.Default.PayPeriodDays; periodStart = baseDate.AddDays(numOfBiWeeks * Properties.Settings.Default.PayPeriodDays); periodEnd = periodStart.AddDays(Properties.Settings.Default.PayPeriodDays - 1);