简体   繁体   English

我需要根据今天的日期生成当前一周的记录

[英]I need to generate records for current week based on today's date

I need to generate records for date, In time and out time for current week based on todays date and empcode(Sql server 2008 r2),when a user clicks Current week in dropdownlist in asp.net web application. 当用户在asp.net Web应用程序的下拉列表中单击“当前星期”时,我需要根据今天的日期和empcode(Sql server 2008 r2)生成日期记录,当前星期的时间和超时时间。

I have stored procedure like this: 我有这样的存储过程:

select @empcode as empcode, 
  min(eventdate) as firstIn, 
  max(eventdate) as lastout 
from eurevents 
where empcode = @empcode 
  and convert(Varchar,logdate,110) = convert(Varchar, @searchdate, 110);

I am a trainee newly joined. 我是新加入的实习生。 so please help me out 所以请帮帮我

This bit of code will bring you back all records within the current week. 这一段代码将带您返回当前一周内的所有记录。 If you only want the working week (without weekends) change the *7 and +7 to *5 and +5 如果只希望工作一周(无周末),请将* 7和+7更改为* 5和+5

 BETWEEN dateadd(dd,(datediff(dd,-53684,getdate())/7)*7,-53684) 
    AND dateadd(dd((datediff(dd,-53684,getdate())/7)*7)+7,-53684)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM