c# - Get records of last week adding by datetime in database -
c# - Get records of last week adding by datetime in database -
i'm using asp.net mvc in project. database table includes records. table has datetime column records. want records of lastly week adding. lastlyrecords
is:
datetime.now = 04.04.2015 lastweekdatetime = 28.04.2015 lastweekdatetime < lastlyrecords < datetime.now
have method accepts "start date" , "end date" parameters.
call start/end date like:
getrecords(datetime.now.addweeks(-1), datetime.now);
for there, can have stored procedure fetch records between date range (or similar entity framework or whatever you're using).
you can similar in t-sql via getdate() , dateadd(), it's arguably improve range calculation in calling code (because it's more business logic thing info access thing).
c# asp.net asp.net-mvc entity-framework model-view-controller
Comments
Post a Comment