sql server :周日到周六为一周 datediff(week,DepartureTime,getdate())=0
C# :周日到周六为一周
private bool IsInSameWeek(DateTime dtmS, DateTime dtmE)
{
DateTime temp1 = dtmS.AddDays(-(int)dtmS.DayOfWeek).Date;
DateTime temp2 = dtmE.AddDays(-(int)dtmE.DayOfWeek).Date;
bool result = temp1 == temp2;
return result;
}
sql server:周一到周日为一周 ,设置数据库服务器时间 1为一周的第一天
SET DATEFIRST 1
C#:周日到周六为一周
private bool IsInSameWeek(DateTime dtmS, DateTime dtmE)
{
TimeSpan ts = dtmE - dtmS;
double dbl = ts.TotalDays;
int intDow = Convert.ToInt32(dtmE.DayOfWeek);
if (intDow == 0) intDow = 7;
if (dbl >= 7 || dbl >= intDow) return false;
else return true;
}