Filtering a dataview

U

Usarian Skiff

Hi all,

I'm trying to filter a dataview down to a 24-hour period.

I tried just rowfilter='mydate' (mydate being something like 03/26/2005) and
it came up with nothing (due to the stupid time stamp).

I'm tried rowfilter>'03/25/2005' AND <'03/27/2005' and ended up with every
entry after midnight on the 25'th.

so now I'm trying >='03/26/2005' AND <'03/27/2005' and am getting every
entry from 03/2/2005

I'm going CrAzY! Can anyone save my sanity here!?

Usarian Skiff
 
E

Eric Dreksler

By 24 hours do you mean the last 24 hours or just today?

How about something like
dv.RowFilter = "tabledate => " & Now.AddHours(-24) & " AND tabledate <= " &
Now()
Eric Dreksler
 
J

Jay B. Harlow [MVP - Outlook]

Usarian,
I normally use # to delimit the dates, have you tried something like:

Dim view As New DataView(table)
view.RowFilter = "date1 >= #2/17/2005# and date1 < #2/18/2005#"
For Each row As DataRowView In view
Debug.WriteLine(row!date1)
Next

Given a table such as:
Dim table As New DataTable
table.Columns.Add("date1", GetType(DateTime))

table.Rows.Add(New Object() {#2/16/2005 9:00:00 AM#})
table.Rows.Add(New Object() {#2/16/2005 12:00:00 PM#})
table.Rows.Add(New Object() {#2/16/2005 7:00:00 PM#})
table.Rows.Add(New Object() {#2/16/2005 1:00:00 PM#})

table.Rows.Add(New Object() {#2/17/2005 9:00:00 AM#})
table.Rows.Add(New Object() {#2/17/2005 12:00:00 PM#})
table.Rows.Add(New Object() {#2/17/2005 7:00:00 PM#})
table.Rows.Add(New Object() {#2/17/2005 1:00:00 PM#})

table.Rows.Add(New Object() {#2/18/2005 9:00:00 AM#})
table.Rows.Add(New Object() {#2/18/2005 12:00:00 PM#})
table.Rows.Add(New Object() {#2/18/2005 7:00:00 PM#})
table.Rows.Add(New Object() {#2/18/2005 1:00:00 PM#})

Hope this helps
Jay
 
C

Cor Ligthert

Usarian,

Will you please be so kind to place questions not multiposted however when
relevant crossposted
Sending 1 message to more newsgroups in a time.

Now there where 4 people giving you an answer, where you did not even tell
now that Jay's answer did fit your question in this newsgroup.

Thanks in advance.

Cor
 

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