Answer the question
In order to leave comments, you need to log in
How to issue a query to the database if you need to be based on a date?
Look here is the code -
DateTime TodayDate = DateTime.Now.Date; // init
var query = from o in this.dbContext.RentCarDBSet
where (DbFunctions.TruncateTime(o.StartDate) >= TodayDate)
orderby RentCarDB.StartDate
select o;
this.rentCarDBViewSource.Source = query.ToList();
Those. o.StartDate + o.Duration (where first is DateTime and second is String
(number of days)) >= TodayDate
Answer the question
In order to leave comments, you need to log in
The number of days as a string is, of course, lovely.
At least it is necessary to know that for a DBMS.
SQLServer has a DATEADD(datepart , number , date) function. In MySql, the DATE_ADD(date,INTERVAL expr type) function.
Convert the string with the number of days to a number, then add using the specified functions to today's date.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question