We help IT Professionals succeed at work.

VB.NET Datatable Select using MySQL Month()

sgaggerj asked
Hi Experts,

I have a MySQL database that I'm pulling into a datatable in vb.net

Using the data table, I need to run a select statement using the MySQL 'Month'


MyTable.Select("OrderID In (100,110,120,130) AND Month(OrderDate)>=1 AND Month(OrderDate) <= 3)

Apparently the select doesn't have that function call defined.  Is there something else that I can use in the select statement, rather than later looping through all the DataRows that are returned and testing the date?

I also tried

MyTable.Select("OrderID IN (100,110,120,130) AND OrderDate >= #1/%/%# AND OrderDate <= #3/%/%#)

But that's not a valid date/time string.

Any suggestions?

Watch Question

Most Valuable Expert 2012
Top Expert 2014
That month wont work in the DataTable.Select. You can use it in MySql select though when filling



Yea I was afraid of that.  I already have all my data in my data table at run time and am working with only the data table.  
I'd rather not add more calls to the DB as what i'm working on now is used by people outside of the LAN (possibly other countries)

I'll loop through the rows instead.

Thanks for your help though!
Most Valuable Expert 2012
Top Expert 2014

Glad to help :-)