Results 1 to 4 of 4

Thread: formating a date to dd/mm/yyyy format

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    formating a date to dd/mm/yyyy format

    Hello,

    I am using a DateTime variable. But l want to change the format of the shortDateString from mm/dd/yyyy to the new format of dd/mm/yyyy.

    I used the code below using, using System.Globalization. However, it won't change to this new format of dd/mm/yyyy

    DateTime today = Convert.ToDateTime(DateTime.Today.ToShortDateString());
    DateTimeFormatInfo dateFormat = new DateTimeFormatInfo();
    dateFormat.ShortDatePattern = "dd/mm/yyyy";
    today.ToString(dateFormat);

    Can anyone help with this.

    Many thanks in advance,

    Steve
    Last edited by steve_rm; Dec 11th, 2004 at 05:26 AM.
    steve

  2. #2
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: query database that contain dates

    It might be a date format problem as you are in the UK. Try reformating the date into a yyyy-mm-dd format and see if that helps.

    DJ

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: formating a date to dd/mm/yyyy format

    Try this :
    Code:
    DateTime today = DateTime.Now.Date;
    MessageBox.Show(today.ToString("dd/MM/yyyy"));

  4. #4
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: formating a date to dd/mm/yyyy format

    Hey thats not the same question I answered. If you are going to ask a different question add resolved to the existing post title and post a new one otherwise the thread just doesn't make sense!

    DJ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width