Select query from datetime field [modified]
-
Hi, I'm trying to create select query (with LINQ) that's checking if a row is already exists in a table (SQL SERVER). this is the query:
var query = from p in dc.OnLineDuties where p.StartDate == start p.EndTime == end select p; return query.ToList();
the tamplate is - "yyyy-mm-dd hh:mm:ss" But i'm not getting any result. Here are the values from the DB:StartDate 2010-11-01 09:00:00.000 EndDate 2010-11-01 10:00:00.000
What i'm doing wrong??? Please assist...modified on Sunday, November 7, 2010 6:28 AM
-
Hi, I'm trying to create select query (with LINQ) that's checking if a row is already exists in a table (SQL SERVER). this is the query:
var query = from p in dc.OnLineDuties where p.StartDate == start p.EndTime == end select p; return query.ToList();
the tamplate is - "yyyy-mm-dd hh:mm:ss" But i'm not getting any result. Here are the values from the DB:StartDate 2010-11-01 09:00:00.000 EndDate 2010-11-01 10:00:00.000
What i'm doing wrong??? Please assist...modified on Sunday, November 7, 2010 6:28 AM
You most likely want to check the dates between the start and end dates, not checking for an exact match as you are doing.
I know the language. I've read a book. - _Madmatt
-
Hi, I'm trying to create select query (with LINQ) that's checking if a row is already exists in a table (SQL SERVER). this is the query:
var query = from p in dc.OnLineDuties where p.StartDate == start p.EndTime == end select p; return query.ToList();
the tamplate is - "yyyy-mm-dd hh:mm:ss" But i'm not getting any result. Here are the values from the DB:StartDate 2010-11-01 09:00:00.000 EndDate 2010-11-01 10:00:00.000
What i'm doing wrong??? Please assist...modified on Sunday, November 7, 2010 6:28 AM
treuveni wrote:
p.EndTime
:confused:
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
You most likely want to check the dates between the start and end dates, not checking for an exact match as you are doing.
I know the language. I've read a book. - _Madmatt
-
treuveni wrote:
p.EndTime
:confused:
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
treuveni wrote:
I wrote it with LINQ, not with ADO.NET
So? I see StartDate and EndTime. Is that what you intend? :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
treuveni wrote:
I wrote it with LINQ, not with ADO.NET
So? I see StartDate and EndTime. Is that what you intend? :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.
-
Hi, I'm trying to create select query (with LINQ) that's checking if a row is already exists in a table (SQL SERVER). this is the query:
var query = from p in dc.OnLineDuties where p.StartDate == start p.EndTime == end select p; return query.ToList();
the tamplate is - "yyyy-mm-dd hh:mm:ss" But i'm not getting any result. Here are the values from the DB:StartDate 2010-11-01 09:00:00.000 EndDate 2010-11-01 10:00:00.000
What i'm doing wrong??? Please assist...modified on Sunday, November 7, 2010 6:28 AM
-
Mark Nischalke wrote:
You most likely want to check the dates between the start and end dates, not checking for an exact match as you are doing.
No, i want to check if the specific date is already in the DB, if not - then i'll insert the row.
In your DB you have StartDate and EndDate. Where is p.EndTime coming from? What is end? Is it a string, a datetime? ??
I know the language. I've read a book. - _Madmatt
-
I guess there's a mistake in the formulation of your Linq query. This should be :
var query = from p in dc.OnLineDuties
where p.StartDate == start && p.EndTime == end
select p; -
Are you sure such a row exists?
Rhys "With no power comes no responsibility"
-
Are you sure such a row exists?
Rhys "With no power comes no responsibility"
goblinTech wrote:
Are you sure such a row exists?
Sure. Here are the two rows from my DB:
DutyId PersonId StartDate EndTime
124 37 2010-11-01 09:00:00 2010-11-01 10:00:00
152 37 2010-09-01 19:00:00 2010-09-01 22:00:00and still, this query dosen't return any results.
modified on Tuesday, November 9, 2010 1:53 AM
-
goblinTech wrote:
Are you sure such a row exists?
Sure. Here are the two rows from my DB:
DutyId PersonId StartDate EndTime
124 37 2010-11-01 09:00:00 2010-11-01 10:00:00
152 37 2010-09-01 19:00:00 2010-09-01 22:00:00and still, this query dosen't return any results.
modified on Tuesday, November 9, 2010 1:53 AM
Can some-one please help me why my query doesn't works?
var query = from p in dc.OnLineDuties where p.StartDate == start p.EndTime == end select p;
Here are the two rows from my DB:DutyId PersonId StartDate EndTime 124 37 2010-11-01 09:00:00 2010-11-01 10:00:00 152 37 2010-09-01 19:00:00 2010-09-01 22:00:00
-
Can some-one please help me why my query doesn't works?
var query = from p in dc.OnLineDuties where p.StartDate == start p.EndTime == end select p;
Here are the two rows from my DB:DutyId PersonId StartDate EndTime 124 37 2010-11-01 09:00:00 2010-11-01 10:00:00 152 37 2010-09-01 19:00:00 2010-09-01 22:00:00
To expand on something Mark Nischalke asked some time ago to which you never replied, what is start, what is end? Are they string's, are they datetime's, what are there values at runtime?
Rhys "With no power comes no responsibility"
-
To expand on something Mark Nischalke asked some time ago to which you never replied, what is start, what is end? Are they string's, are they datetime's, what are there values at runtime?
Rhys "With no power comes no responsibility"
goblinTech wrote:
what is start, what is end?
they are DateTime's.
goblinTech wrote:
what are there values at runtime?
the user inserts the value trough text box and i parse it to a DateTime type. at the end the become dd/MM/yyyy hh:mm:ss formt. The colums ype is also DateTime. 10x
-
goblinTech wrote:
what is start, what is end?
they are DateTime's.
goblinTech wrote:
what are there values at runtime?
the user inserts the value trough text box and i parse it to a DateTime type. at the end the become dd/MM/yyyy hh:mm:ss formt. The colums ype is also DateTime. 10x
But what are the values of start and end at runtime? Can you debug and check?
Rhys "With no power comes no responsibility"
-
But what are the values of start and end at runtime? Can you debug and check?
Rhys "With no power comes no responsibility"