datetime query

  • Thread starter Thread starter jed
  • Start date Start date
J

jed

SELECT (hrs) AS total_hours,(mins)AS total_mins FROM Timerecords WHERE
(workdate between 02/06/2007 and 06/06/2007;

This statement doesn't work because it doesn't have times associated
with the dates.When i store the dates in the database originally it
automatically adds time to them is there anyway i can just enter dates
without the time.Any code examples please! thanks.
 
You should be using a parameterized query for this. You would create
the query string like:

SELECT (hrs) AS total_hours,(mins)AS total_mins FROM Timerecords WHERE
(workdate between @from and @to);

And then you would add two parameters to the SqlCommand you are
generating. You would then set the value of those parameters to the date,
and it will do the rest for you (as well as convert the date to a value that
is not dependent on the locale, which is what you are doing).
 
SELECT (hrs) AS total_hours,(mins)AS total_mins FROM Timerecords WHERE
(workdate between 02/06/2007 and 06/06/2007;

This statement doesn't work because it doesn't have times associated
with the dates.When i store the dates in the database originally it
automatically adds time to them is there anyway i can just enter dates
without the time.Any code examples please! thanks.

Thanks all dont worry managed to sort it out
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top