Solved

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

Posted on 2007-03-27
4
691 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
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

821 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