Solved

NEed to Change System Date Format Programmatically Using VB.NET

Posted on 2003-12-10
7
2,264 Views
Last Modified: 2008-05-28
Hi,
I need to change the System Date Format programmatically to specific format. I should be able to get the current Date format then I should be able to change the System Date Format to dd-MMM-yy. Please help. Only vb.NET Code would be accepted.
0
Comment
Question by:payasiashish
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 2

Expert Comment

by:adomsg
ID: 9918538
txtDate.text =  Format(Date.Now,"dd-MMM-yy")
0
 

Author Comment

by:payasiashish
ID: 9918596
NO this is not what I Want.
I want to Access Regional Settings - Date and the specofy a Format to it, I do not want to format the date I want to get the Current Format of Date In the System and the Change the same (Date Format of the system) Programatically in VB.NET
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9920047
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:payasiashish
ID: 9920406
With this I can retrive the date format however I am not able to set the date. It says its readonly property. Can you help me.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 9920784
You can temporarily override this value:

Imports System.Globalization
Imports System.Threading.Thread
...

      Dim newCulture As CultureInfo = New CultureInfo(CultureInfo.CurrentCulture.Name)
      newCulture.DateTimeFormat.ShortDatePattern = "dd-MMM-yy"
      CurrentThread.CurrentCulture = newCulture
      MsgBox(CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern.ToString)
0
 

Author Comment

by:payasiashish
ID: 9925929
Thanks for the hellp but I am confused with Temporarily override thing. Can you elobrate this. Does this mean this will reset to what it was earlier after the program terminates?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 75 total points
ID: 9927866
I mean it doesn't stick after you close your program--not a permanent change.  I am thinking that this isn't a bad thing, just change it to what you want it to be within your program, and let the user keep what they already have.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MailAddress in vb 4 36
What are the simplest ways to create a Merge Sort? 3 37
Import MySQL data into MS Access using VB.Net interface 5 52
Header Font Size in Grid View 6 27
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…

730 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