Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter by Year from Date in DataView

Status
Not open for further replies.

VBrian

Technical User
Mar 6, 2003
9
US
I am trying to Filter by year and/or month in a date column of a dataview. For example: I would like to see(in my databound datagrid) all of the sales made in 2003(or whatever year is selected from a combo box).

In Visual Basic I was able to perform this by using the following: (Where "dDateOfOrder" is the name of the column in the database)

If cmbYear.ListIndex = 0 Then
sYearFilter = ""
Else
sYearFilter = "(Year([dDateOfOrder]) = " & cmbYear.Text & ")"
End If

datRecords.RecordSource = BuildRecordSource()
datRecords.Refresh

The variable "sYearFilter" is then passed to a function that builds the complete SQL statement which returns the appropriate recordset, to which "datRecords" is bound.

Is there any way to perform this same thing within a dataview?

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top