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
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
Re: formating a date to dd/mm/yyyy format
Try this :
Code:
DateTime today = DateTime.Now.Date;
MessageBox.Show(today.ToString("dd/MM/yyyy"));
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