Link to home
Start Free TrialLog in
Avatar of net_susan
net_susan

asked on

Problem with Dates in Do While (dr.Read())

What's wrong with this?

 if (dr("Date_Only") = (01/01/1900)) then
 (row("Date_Only")= (04/22/2006))
 else
     row("Date_Only")=dr("Date_Only")
 end if
Avatar of Elvio Lujan
Elvio Lujan
Flag of Argentina image

what's error you'r getting?
this should work better, but not sure:
 if (dr("Date_Only") = "01/01/1900") then
 (row("Date_Only")= "04/22/2006")
 else
     row("Date_Only")=dr("Date_Only")
 end if

the isse with yours is that you have a simple numerical division (1/1)/1900 etc, which is NOT a date, even if it looks at the first sight as one.
may be you need to do:

 if (dr("Date_Only") == DateTime.MinValue) then
     row("Date_Only") = Convert.ToDateTime(04/22/2006);
 else
     row("Date_Only") = Convert.ToDateTime(dr("Date_Only").ToString());
 end if
if (dr("Date_Only") == DateTime.MinValue) then
     row("Date_Only") = Convert.ToDateTime("04/22/2006");
 else
     row("Date_Only") = Convert.ToDateTime(dr("Date_Only").ToString());
 end if
Avatar of net_susan
net_susan

ASKER

This got a fast response.  :)

BC30035: Syntax error.

for both ways.
sorry in vb:

if dr("Date_Only") = DateTime.MinValue then
     row("Date_Only") = Convert.ToDateTime("04/22/2006")
 else
     row("Date_Only") = Convert.ToDateTime(dr("Date_Only").ToString())
 end if
not lem's, one sec...
Lem's failed on this line:

if (dr("Date_Only") == DateTime.MinValue) then

Expression expected.
Ok, that didn't fail.
try:
if dr("Date_Only") = "01/01/1900" then

or

if dr("Date_Only") = Convert.ToDateTime("01/01/1900") then
but...

what is this? if dr("Date_Only") = DateTime.MinValue then

is the MinValue actually 01/01/1900?

because as far as I know, it's a date I created.
yes the minvalue is "01/01/1900"... but if it don't work for you use the your string
this seems to work:

if dr("Date_Only") = "01/01/1900" then

but, it shows as 4/22/2006 12:00:00 AM

when I had the stored procedure bring it down to 4/22/2006 before.
ASKER CERTIFIED SOLUTION
Avatar of Elvio Lujan
Elvio Lujan
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
maybe it did work. it didn't fail. I haven't tested it much yet, but if you could just get the time out we'll be good to go!
 
Yippee.