p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).

Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 1st, 2007, 03:30 AM
Registered User
 
Join Date: Sep 2007
Location: Pune, maharashtra, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to convert dd/MM/yyyy to MM/dd/yyyy

How to convert textbox value date from dd/MM/yyyy to MM/dd/yyyy in vb.net +asp.net

Rg2005
__________________
Rg2005
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old January 17th, 2008, 06:30 PM
Registered User
 
Join Date: Jan 2008
Location: , , Australia.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First you need to have a date object. So, for instance:

Dim myDate as Date

Alternatively, if your string object contains a vailid date, eg, "20/01/2007" then you can cast it to a date using CDate(myDate, Date)

For both you would use the .toString method to format it.

myDate.toString("MM/dd/yyyy")

or

CDate(myDate, Date).toString("MM/dd/yyyy")

If myDate was a string variable. Note that both examples only return a formatted date string. It doesn't change the date format within the date object. You need to change the Windows Regional Settings to change the format the system date.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old November 7th, 2008, 06:42 PM
Registered User
 
Join Date: Nov 2008
Location: philadelphia, pa, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

interesting.

I just upconverted a vb program from vb2005 to vb2008 and ran into a similar issue that doesn't appear to be easy to find anywhere else on the web. the closest i came to an answer was this post, which was very helpful (thank you very much)!

my tool reads lines from a csv file and does stuff with the data. some of the data entries are dates, but because i read a line at a time and split at commas into an array, all entries must come in as strings. in vb2005, this was not an issue: the dates were managed and manipulated like normal strings and everything was fine.

as soon as i upgraded to vb2008, things changed. vb2008 decided it was smarter than its operator, and automatically reconfigured the dates from "MM/dd/yyyy" and "MM/dd/yyyy hh:mm" to "MM-dd-yyyy" and "MM-dd-yyyy hh:mm" respectively.

thankfully, using your CDate().ToString() method, I was able to easily re-reconfigure the strings back to what they originally were. this saved me loads of time reconfiguring the entire program.

Please forward all my mail to the corner of pork & beans.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date dd-mm-yyyy John2112 SQL Server 2000 2 March 16th, 2007 06:15 AM
mm/dd/yyyy to dd/mm/yyyy Ashleek007 Beginning PHP 2 September 27th, 2006 07:35 AM
convert "MM/dd/yyyy" to "dd/MM/yyyy" xin56 General .NET 4 March 28th, 2005 05:33 AM
Convert getdate() -> dd/mm/yyyy? minhpx SQL Language 1 January 3rd, 2005 09:30 AM
Date formats... dd/mm/yyyy SeanW Classic ASP Databases 3 June 14th, 2004 01:34 PM



All times are GMT -4. The time now is 03:30 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc