0

Hi,
I need to retrieve records from access database in c# which falls between date1 and date2. anyone could help me out this...

2
Contributors
3
Replies
14
Views
3 Years
Discussion Span
Last Post by ChrisHunter
0

What have you done so far?

If you're table has a date column in it do SELECT field1, field2 FROM MyTable WHERE dateField >= date1 AND dateField <= date2

Edited by ChrisHunter

0

I have tried this already. It doesn't take the date values.
i need to retrieve records which match with one value and falls between 2 date ranges.
ex:- Select * from Tablename where value = '" + x+"' and datefield >= '"+ date1+ "' and datefield<='" +date2+ "'

0

What is value is it a varchar type of int?

"SELECT * FROM Tablename WHERE value = '" + x + "' AND datefield >= CONVERT(DATETIME, '" + date1 + "', 103) AND datefield <= CONVERT(DATETIME, '" + date2 + "', 103)"

To change the format of the date time you need to change the 103 value use above to which ever format code you need.

If X is an int and not a varChar then take the single quotation marks from around the X (').

I hope this helps, let me know how you get on.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.