Web.11
Web.11

Reputation: 416

Vb.Net Search between two dates ms access

I'm using vb.net Windows Form Application, and I have two datepicker and I want to filter between two dates... I've tried this code :

Me.DBBindingSource.Filter = "[Data ardhjes] BETWEEN " & dtpDataArdhjes.Value.Date & " AND " & dtpDataArdhjesNE.Value.Date

And I got this error:

Additional information: The expression contains unsupported operator 'Between'.

and some other codes but it does not work.. [Data ardhjes] is on table, and dtpDataArdhjes is datetimepicker from the table and dtpDataARdhjesNe is just a dateTimepicker, sa I want to search between two dates in same column named [Data Ardhjes] any suggestion please ?

Upvotes: 0

Views: 341

Answers (2)

Beldi Anouar
Beldi Anouar

Reputation: 2180

Try this :

 Me.DBBindingSource.Filter = "[Data ardhjes] BETWEEN " & dtpDataArdhjes.Value.ToString("#yyyy/MM/dd#") & " 
    AND " &  dtpDataArdhjesNE.Value.ToString("#yyyy/MM/dd#")

Upvotes: 1

Web.11
Web.11

Reputation: 416

I got the answer:

Me.DBBindingSource.Filter = String.Format("[Data ardhjes] >= #{0:M/dd/yyyy}# AND [Data ardhjes] <= #{1:M/dd/yyyy}#", _
                                 dtpDataArdhjes.Value, _
                                 dtpDataArdhjesNE.Value)

It works great now..

Upvotes: 0

Related Questions