[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2274
  • Last Modified:

NEed to Change System Date Format Programmatically Using VB.NET

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
payasiashish
Asked:
payasiashish
  • 3
  • 3
1 Solution
 
adomsgCommented:
txtDate.text =  Format(Date.Now,"dd-MMM-yy")
0
 
payasiashishAuthor Commented:
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
 
Bob LearnedCommented:
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
payasiashishAuthor Commented:
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
 
Bob LearnedCommented:
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
 
payasiashishAuthor Commented:
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
 
Bob LearnedCommented:
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

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now