HOW to filter by Hour using DataView.RowFilter ?

  • Thread starter Thread starter David
  • Start date Start date
D

David

Hi, I use DataView to filter my record.
But when I use:

ls_filter += " and DATEPART(hh, CA103)=" + i ;
mydv.RowFilter = ls_filter;

I got error.

How should I filter by hour using DataView.Rowfilter?

Thanks for kind advice, David.
 
Hi David,

You could return the DATEPART of you datetime column as a seperate column in
your original SQL query. You could then filter by this field very easily in
your DataView's RowFilter.

e.g Instead of:

SELECT TheDateColumn FROM TheTable

do this:

SELECT TheDateColumn, DATEPART(month, TheDateColumn) AS [MonthFilterCol]
FROM TheTable

Regards,

Peter
 

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