Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Cannot perform '<' operation on System.DateTime and System.Double.

Posted on 2012-12-28
2
Medium Priority
?
573 Views
Last Modified: 2012-12-31
Cannot perform '<' operation on System.DateTime and System.Double.


 dvholidays = New DataView(dtholidays, "Date <" & enddate.AddDays(1).ToShortDateString & " and Date >" & startdate.AddDays(-1).ToShortDateString & "", "", DataViewRowState.CurrentRows)

Open in new window

0
Comment
Question by:runnerjp2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38727635
if you check the string you build, you would see that it would be a "math expression"

you need to put quotes:
 dvholidays = New DataView(dtholidays, "Date < '" & enddate.AddDays(1).ToShortDateString & "' and Date > '" & startdate.AddDays(-1).ToShortDateString & "' ", "", DataViewRowState.CurrentRows)

Open in new window


this will resolve the error, but it will eventually result in bad results if the comparison of the values is not "expected".

see this article:
http://www.experts-exchange.com/Database/Miscellaneous/A_1499-DATE-and-TIME-don%27t-be-scared-and-do-it-right-the-first-time.html
it's not about data views, so it won't show the relevant solutions, but ideas to think at least.
as I indicated in your previous question, you may need to solve this differently.
make so that the "date" field in the dataset is returned as string in the format 'YYYYMMDD' to make your > and < conditions to work ...
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 38728226
As suggested in your other question, use CDate function

 dvholidays = New DataView(dtholidays, "Date < CDate('" & enddate.AddDays(1).ToShortDateString & "') and Date > CDate('" & startdate.AddDays(-1).ToShortDateString & "') ", "", DataViewRowState.CurrentRows)

Open in new window

0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

670 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