locked
Date Format RRS feed

  • Question

  • How can i set the format of the date like this January 9, 2010?
    this is my code

    lbllastloggedin.Text = DateAndTime.Today

    the output is 03/14/10

    i want the output to be like this March 14, 2010

    thanks
    please help
    Sunday, March 14, 2010 2:49 AM

Answers

  • Predefined Date/Time Formats (Format Function)

    Long Date, Medium Date, or D

    Displays a date according to your current culture's long date format. For example, Wednesday, March 12, 2008.




        
    Private Sub Button1_Click(ByVal sender As System.Object, _
                                  
    ByVal e As System.EventArgs) Handles Button1.Click

            TextBox1.Text = Format(Now, 
    "Long Date")

        
    End Sub

    Coding4fun Be a good forum member mark posts that contain the answers to your questions or those that are helpful
    Please format the code in your posts with the button . Makes it easier to read . Or use the Forum Code Formatter by JohnWein http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/bf977a14-d9d4-4e84-9784-bf76b9e23261
    Sunday, March 14, 2010 3:39 AM
  • Yes it is also advised to use system defined setting for culture aware data. So Long Date format comes from your Windows setting, if it is different than what is standard(blame user), you might get different result. If you want to define your own format regardless what system has defined, then you could change style portion in bdbodger's code.

      lbllastloggedin.Text = Format(Now, "MMMM dd, yyyy")

    Arjun Paudel
    Sunday, March 14, 2010 5:20 AM

All replies

  • Predefined Date/Time Formats (Format Function)

    Long Date, Medium Date, or D

    Displays a date according to your current culture's long date format. For example, Wednesday, March 12, 2008.




        
    Private Sub Button1_Click(ByVal sender As System.Object, _
                                  
    ByVal e As System.EventArgs) Handles Button1.Click

            TextBox1.Text = Format(Now, 
    "Long Date")

        
    End Sub

    Coding4fun Be a good forum member mark posts that contain the answers to your questions or those that are helpful
    Please format the code in your posts with the button . Makes it easier to read . Or use the Forum Code Formatter by JohnWein http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/bf977a14-d9d4-4e84-9784-bf76b9e23261
    Sunday, March 14, 2010 3:39 AM
  • Label1.Text = Now.ToLongDateString


    Asgar
    Sunday, March 14, 2010 4:50 AM
  • Yes it is also advised to use system defined setting for culture aware data. So Long Date format comes from your Windows setting, if it is different than what is standard(blame user), you might get different result. If you want to define your own format regardless what system has defined, then you could change style portion in bdbodger's code.

      lbllastloggedin.Text = Format(Now, "MMMM dd, yyyy")

    Arjun Paudel
    Sunday, March 14, 2010 5:20 AM
  • thANk you
    Sunday, March 14, 2010 7:21 AM