5
I have a field in the database which is in the following format: YYYYMM
Using the past I can normally search these fields:
WHERE I.DT_INCL >= @inicio
AND I.DT_INCL <= @final
When trying to pass the query to Ingl returns the following error: Operator '>=' cannot be Applied to operands of type 'string' and 'string'
(from incorporacao in Incorporacao.FoundEntities
where incorporacao.DataInclusao >= inicio && incorporacao.DataInclusao <= final
select incorporacao).ToList();
I arrived at two possible solutions:
Create a method that returns a DateTime
always putting the day fixed or leaving the field as whole.
Which of these two solutions is the most correct in this context? The database is old and I cannot modify it.
The ideal is to use Datetime or Smalldatetime fields in the database to make comparisons. When using Nvarchar or Varchar for dates in the database, you run the risk of finding something other than a date, then exceptions may occur.
– 2madera