Solved

How to do a .Select() or set a rowfilter on a Dataset with "Right" function

Posted on 2007-03-27
4
694 Views
Last Modified: 2012-08-13
Goodday,
How can I do a select on a dataset table with the "Right" function on a string ?
Problem now is that the "Right" function is not usable in the rowfilter or a .Select()

Example :
ds.Tables("Overview").DefaultView.RowFilter = "right([Dates],4 = " & dat_year

The table in the dataset ds contains the column Dates in which text is stored like :
"01.01.2005 - 01.02.2005"   and I would like to do a select on the last 4 char.


0
Comment
Question by:RonaldZaal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 21

Expert Comment

by:tovvenki
ID: 18798618
HI,
instead of checking the year part check the date from 01/01/date_year till 31/01/date_year
startDate as string
endDate as string
startDate = "01/01/" & dat_year
endDate = "31/01/" & dat_year
ds.Tables("Overview").DefaultView.RowFilter = "[Dates] >= " & startDate & " and [Dates] <= " & endDate

I hope that this helps you


Kind Regards
Venki
0
 
LVL 2

Expert Comment

by:alfredwhang
ID: 18798837
try:

1) ds.Tables("Overview").DefaultView.RowFilter = "Date>=#01-01" & Yr & "# AND Date<#01-01" & Yr +1 & "#")

2) ds.RowFilter = "Convert(Date,'System.DateTime') =" & Yr

3) ds.Tables("Overview").DefaultView.RowFilter = "Year(Date) = " & Yr
0
 
LVL 2

Accepted Solution

by:
alfredwhang earned 500 total points
ID: 18798849
sorry:

don't forget the # in 1

and 2) should be:

ds.RowFilter = "(Convert(Date,'System.DateTime')).Year =" & Yr
0
 
LVL 5

Author Comment

by:RonaldZaal
ID: 18836534
To my surprise I left the Q without a note.
Better late then never I guess

Thanks alfredwhang !

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question