Link to home
Start Free TrialLog in
Avatar of Jimbo99999
Jimbo99999Flag for United States of America

asked on

Vb.Net - Convert 8/21/2013 to YYYYMMDD

Good Day Experts!

I am "stuck" and have tried searching the net for assistance.

I have a date 8/21/2013 from my SQL Server db that I need to convert to YYYYMMDD.  The column in the database is defined as datatime.  Here is what I am doing so far:

Dim InvDate As Date
InvDate = rdrHdr.Item("Invoice Date")

When I am stepping through the code and hover over InvDate is get 8/21/2013.  How can I convert this to YYYYMMDD?

Thanks for the help,
jimbo99999
SOLUTION
Avatar of Ess Kay
Ess Kay
Flag of United States of America 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
SOLUTION
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
Try if this helps

Dim InvDate As Date
InvDate = rdrHdr.Item("Invoice Date")
MessageBox.Show(InvDate.ToString("yyyy-MM-dd"))

Open in new window


Dim InvDate As Date
InvDate = rdrHdr.Item("Invoice Date")
MessageBox.Show(InvDate.ToString("yyyyMMdd"))

Open in new window

@AkilaPalanimuthu

Your suggestion is just a combination of esskayb2d's and my own comment (except you are relying on implicit type conversion).
ASKER CERTIFIED SOLUTION
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
Avatar of Jimbo99999

ASKER

Thanks everyone for your help.  It is working now.