filter expression with date AND TIME

M

MajorTom

Hello everybody

I using an dataview rowfilter expression to filter some record from one
dataset, is I only working with the date portion no problem, but how do I
use the date and the time for filter some records ?
the code that I have is like this one:

crit1 = "fecha >= #"+dtpDesde.Value.ToString("MM/DD/YYYY")+"#";
crit2 = "fecha <= #"+dtpHasta.Value.ToString("MM/DD/YYYY")+"#";
filtro = crit1 + " AND " + crit2 ;

my datetime picker dtpDesde and dtpHasta have the time in there format and
the field fecha is datetime and I want to filter by time to.

Please, any help ?

MajorTom
 
B

Bob Grommes

If the Value property of the controls is a datetime variable then just add
the time to the format string you already have. If the time is stored
separately then create a TimeSpan instance from the time value and add it to
the date, and then format it all together.

--Bob
 
M

MajorTom

thank for your help

like this:
....ToString("MM/dd/yyyy HH:mm")+"#";

I going to test it

Thanks againg

MajorTom
 

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

Top