Solved

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

Posted on 2012-12-28
2
570 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 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

695 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