English(Canadian) - SQL_Latin1_General_CP1_CI_AS
string
dateCreated = this.drawingsGrid.ActiveRow.Cells["Date_Created"].Value.ToString();
returns 2/10/2001 instead of 10/02/12 which is what is displayed in the grid and stored in the DB.
Anyone have any suggestions?
An option would be to first format the value in the right DateTime format and then get the string value.
The formatting can be done the same way as the grid column is formatted in the InitializeLayout. If there is no formatting done there then I am curious why the Value returns another format then the ToString value.
Hello,
If you are sure that your value is of tipe DateTime the you could simply use
dateCreated = ((DateTime)this.drawingsGrid.ActiveRow.Cells["Date_Created"].Value).ToString("dd/MM/yyyy");
Also I will recomed to review the following link in MSD about ToString() method of DateTimeobject.
http://msdn.microsoft.com/en-us/library/k494fzbf.aspx
Please let me know if you have any further questions.
Hi Daan,
It looks like the mask is null;
null = this.drawingsGrid.DisplayLayout.Bands[0].Columns["Date_Created"].MaskInput;
This only happens when the PC's regional settings be set to English (Canada),and the SQL Server's collation is SQL_Latin1_General_CP1_CI_AS.
Hi Hristo,
The column is of type datetime. In this case we comparing this date to a date a customer has
selected from a monthCalendar in order to make sure that the monthCalendar date is later
than the date_created date. Since I haven't any control of how our customers set up ther db's
reformating the date here might work but not if the db were (English US) or something else.