Check your database to make sure that the data type is set to date time.
If that is not the case, if you are using a string, parse as a date then pass into the string.
You can use Cdate to do this.
Begginnerdev
Practically a Posting Shark
861 posts since Apr 2010
Reputation Points: 184
Solved Threads: 141
Skill Endorsements: 8
Try this :
dtpEqualTo.Value.ToString("yyyy-MM-dd")
Jx_Man
Senior Poster
3,522 posts since Nov 2007
Reputation Points: 1,468
Solved Threads: 514
Skill Endorsements: 64
I've seen this error when the date passed as criteria is not in the same format as the server expects (SQL profile with regional settings MM-DD-YYYY and client passing date with format DD-MM-YYYY).
Try to SET DATEFORMAT DMY (replace DMY with the appropriate format as you datetimepicker's format) in the same command, just before your select, like this:
If TodayToolStripMenuItem.Checked = True Then
query = "SET DATEFORMAT DMY Select * from INCIDENTS where DateReported='" & dtpEqualTo.Value.Date & "'"
PS: If I remember correctly the DATEFORMAT will be persistent for the session until changed or connection is closed.
adam_k
Veteran Poster
1,057 posts since Jun 2011
Reputation Points: 274
Solved Threads: 205
Skill Endorsements: 11
Question Answered as of 1 Year Ago by
Jx_Man,
Begginnerdev
and
adam_k