?
Solved

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

Posted on 2006-04-21
16
Medium Priority
?
482 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:net_susan
  • 8
  • 7
16 Comments
 
LVL 18

Expert Comment

by:Elvio Lujan
ID: 16511643
what's error you'r getting?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 16511645
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
 
LVL 18

Expert Comment

by:Elvio Lujan
ID: 16511659
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:Elvio Lujan
ID: 16511668
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
 
LVL 1

Author Comment

by:net_susan
ID: 16511679
This got a fast response.  :)

BC30035: Syntax error.

for both ways.
0
 
LVL 18

Expert Comment

by:Elvio Lujan
ID: 16511681
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
 
LVL 1

Author Comment

by:net_susan
ID: 16511684
not lem's, one sec...
0
 
LVL 1

Author Comment

by:net_susan
ID: 16511699
Lem's failed on this line:

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

Expression expected.
0
 
LVL 1

Author Comment

by:net_susan
ID: 16511704
Ok, that didn't fail.
0
 
LVL 18

Expert Comment

by:Elvio Lujan
ID: 16511708
try:
if dr("Date_Only") = "01/01/1900" then

or

if dr("Date_Only") = Convert.ToDateTime("01/01/1900") then
0
 
LVL 1

Author Comment

by:net_susan
ID: 16511721
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
 
LVL 18

Expert Comment

by:Elvio Lujan
ID: 16511734
yes the minvalue is "01/01/1900"... but if it don't work for you use the your string
0
 
LVL 1

Author Comment

by:net_susan
ID: 16511736
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
 
LVL 18

Accepted Solution

by:
Elvio Lujan earned 2000 total points
ID: 16511764
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
 
LVL 1

Author Comment

by:net_susan
ID: 16511767
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
 
LVL 1

Author Comment

by:net_susan
ID: 16511779
Yippee.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

839 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