Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 27th, 2005, 09:44 PM
Registered User
 
Join Date: Mar 2005
Location: , , Singapore.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default convert "MM/dd/yyyy" to "dd/MM/yyyy"

Can anyone help me on how to convert "MM/dd/yyyy" to "dd/MM/yyyy"?
Thanks... :D
Below is my code:
Dim stringdate As String = "23/03/05"
Dim dd As Integer = System.Convert.ToInt32(stringdate.Substring(0, 2))
Dim mm As Integer = System.Convert.ToInt32(stringdate.Substring(3, 2))
Dim yyyy As Integer = System.Convert.ToInt32(stringdate.Substring(6, 4))

Dim dt As DateTime = New DateTime(yyyy, mm, dd)
dt = FormatDateTime(dt, "#d/m/y#")
Reply With Quote
  #2 (permalink)  
Old March 27th, 2005, 10:06 PM
Authorized User
 
Join Date: Mar 2004
Location: Rawang, Selangor, Malaysia.
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You may try using this:

Dim stringDate As String = "23/03/05"
Dim ArrDate() As String
Dim DTddMMyyyy As DateTime

ArrDate = split(stringDate, "/")
DTddMMyyyy = ctype(string.concat(ArrDate(1), "/", ArrDate(0), "/", ArrDate(2)), DateTime)
Reply With Quote
  #3 (permalink)  
Old March 27th, 2005, 11:46 PM
Registered User
 
Join Date: Mar 2005
Location: kl, kl, Malaysia.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

if u r using vb.net just try this code

msgbox today.date & "/" & today.month & "/" today.year

it worked out for me

try it!!!

Reply With Quote
  #4 (permalink)  
Old March 28th, 2005, 12:10 AM
Registered User
 
Join Date: Mar 2005
Location: kl, kl, Malaysia.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi
  try this, function that converts date format !!!!

Public Sub changedateformat()
    Dim Msg As String 'Declare variables.
    Dim SecondDate As Date
    SecondDate = CDate(editCDTDATE.Text)
    'editcdtdate is date entered by user in text box
    Msg = DatePart(DateInterval.Day, SecondDate) & "/" & DatePart (DateInterval.Month, SecondDate) & "/" & DatePart(DateInterval.Year, SecondDate)
    editCDTDATE.Text = msg
End Sub

Reply With Quote
  #5 (permalink)  
Old March 28th, 2005, 05:33 AM
Registered User
 
Join Date: Mar 2005
Location: , , Singapore.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help but I have already solve the problem. :D
I need to insert the date according to the computer's regional settings.

Dim dd As Integer = System.Convert.ToInt32(stringdate.Substring(0, 2))
Dim mm As Integer = System.Convert.ToInt32(stringdate.Substring(3, 2))
Dim yyyy As Integer = System.Convert.ToInt32(stringdate.Substring(6, 4))

Dim dt As DateTime = New DateTime(yyyy, mm, dd)
dt = FormatDateTime(dt, DateFormat.LongDate)

This website provide me the information.
http://msdn.microsoft.com/library/de...atdatetime.asp

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to convert dd/MM/yyyy to MM/dd/yyyy Rg2005 VB.NET 2002/2003 Basics 2 November 7th, 2008 06:42 PM
Date dd-mm-yyyy John2112 SQL Server 2000 2 March 16th, 2007 05:15 AM
mm/dd/yyyy to dd/mm/yyyy Ashleek007 Beginning PHP 2 September 27th, 2006 06:35 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 12:34 PM



All times are GMT -4. The time now is 05:29 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.