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

Recommended Answers

All 3 Replies

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

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+ "'

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.