Solved

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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