Problem Formatting Date

W

Wayne Wengert

I am using VB.NET - VSNET 2003 and accessing data from an SQL Server. I am
trying to convert a datetime field retrieved from the DB to a format like
"MM/DD/YYYY" - I want results like "10/28/2004". I am trying the code:

CDate((rdr1.Item("Date"))).ToString("MM/DD/YYYY")

but when I look at the output it looks like this:

02/DD/YYYY

Here is a copy of the test I did while stepping through the code:

?CDate(rdr1.Item("Date")).ToString("MM/DD/YYYY")

"02/DD/YYYY"



What am I doing wrong?



Wayne
 
H

Herfried K. Wagner [MVP]

Wayne Wengert said:
CDate((rdr1.Item("Date"))).ToString("MM/DD/YYYY")

but when I look at the output it looks like this:

02/DD/YYYY

\\\
.... = foo.ToString("MM/dd/yyyy")
///
 
W

Wayne Wengert

Herfried & Jay;

Boy, am I feeling stupid. I overlooked the case sensitivity. Thanks for the
help.

Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top