Test Date

  • Thread starter Thread starter Larry Rebich
  • Start date Start date
L

Larry Rebich

In VB6 I could do something like:

If dMyDate<=2 Then

would return true if the date was not a recent date.

How can I do this in VB2005?

I've tried Cdbl(dMyDate)<=2 but I get an error message telling me I can't do
this 'cast'.

I've tried Google but can't find any examples.

Larry Rebich
 
I am not sure why anyone would want to write code that was so indeterminate,
even if Visual Basic allowed it. :-)

AFAIK, there is no function available to test a date as a double.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
 
Larry,

The same as in VB6 probably, I assume that the code you thinking about is
not the code that you show, I have never seen a date as a single digit

You mean probably something as
dim dMyDate as integer = MyDateComplete.DayOfWeek

if dMyDate <= 2 then

Cor
 
Actually in VB Date is a Double so the value 2 is a legal date as you can
verify with CDate(2) - which is 1.1.1900. So to get the same result (if you
really wish to to that - sometimes it's not very advisable to port from
legacy code to .NET 1 by 1) it would be:

if (dMyDate <= new DateTime(1900, 1, 1))

Regards

Jochen
 
Back
Top