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
LVL 1
net_susanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Elvio Lujan.Net Senior DeveloperCommented:
what's error you'r getting?
0
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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.
0
Elvio Lujan.Net Senior DeveloperCommented:
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
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Elvio Lujan.Net Senior DeveloperCommented:
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
0
net_susanAuthor Commented:
This got a fast response.  :)

BC30035: Syntax error.

for both ways.
0
Elvio Lujan.Net Senior DeveloperCommented:
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
0
net_susanAuthor Commented:
not lem's, one sec...
0
net_susanAuthor Commented:
Lem's failed on this line:

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

Expression expected.
0
net_susanAuthor Commented:
Ok, that didn't fail.
0
Elvio Lujan.Net Senior DeveloperCommented:
try:
if dr("Date_Only") = "01/01/1900" then

or

if dr("Date_Only") = Convert.ToDateTime("01/01/1900") then
0
net_susanAuthor Commented:
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.
0
Elvio Lujan.Net Senior DeveloperCommented:
yes the minvalue is "01/01/1900"... but if it don't work for you use the your string
0
net_susanAuthor Commented:
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.
0
Elvio Lujan.Net Senior DeveloperCommented:
ummm then:

if dr("Date_Only") = "01/01/1900" then
     row("Date_Only") = Convert.ToDateTime("04/22/2006").ToString().SubString(0,10)
 else
     row("Date_Only") = Convert.ToDateTime(dr("Date_Only").ToString()).ToString().SubString(0,10)
 end if
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
net_susanAuthor Commented:
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!
 
0
net_susanAuthor Commented:
Yippee.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.