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
if (dr("Date_Only") = (01/01/1900)) then
(row("Date_Only")= (04/22/2006))
else
row("Date_Only")=dr("Date_
end if
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.
if (dr("Date_Only") = "01/01/1900") then
(row("Date_Only")= "04/22/2006")
else
row("Date_Only")=dr("Date_
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/2 006);
else
row("Date_Only") = Convert.ToDateTime(dr("Dat e_Only").T oString()) ;
end if
if (dr("Date_Only") == DateTime.MinValue) then
row("Date_Only") = Convert.ToDateTime(04/22/2
else
row("Date_Only") = Convert.ToDateTime(dr("Dat
end if
if (dr("Date_Only") == DateTime.MinValue) then
row("Date_Only") = Convert.ToDateTime("04/22/ 2006");
else
row("Date_Only") = Convert.ToDateTime(dr("Dat e_Only").T oString()) ;
end if
row("Date_Only") = Convert.ToDateTime("04/22/
else
row("Date_Only") = Convert.ToDateTime(dr("Dat
end if
ASKER
This got a fast response. :)
BC30035: Syntax error.
for both ways.
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("Dat e_Only").T oString())
end if
if dr("Date_Only") = DateTime.MinValue then
row("Date_Only") = Convert.ToDateTime("04/22/
else
row("Date_Only") = Convert.ToDateTime(dr("Dat
end if
ASKER
not lem's, one sec...
ASKER
Lem's failed on this line:
if (dr("Date_Only") == DateTime.MinValue) then
Expression expected.
if (dr("Date_Only") == DateTime.MinValue) then
Expression expected.
ASKER
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
if dr("Date_Only") = "01/01/1900" then
or
if dr("Date_Only") = Convert.ToDateTime("01/01/
ASKER
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.
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
ASKER
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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!
ASKER
Yippee.