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.
Hello ,
Thank you for your feedback.
Please let me know if you have any further questions related to Infragistics.
I didn't write this code section so I'm not sure why we're doing this but the following code must
force the dates back to US format while they still display Canadian format. Sorry.
Bob
columnName)
{
;
returnValue;
try
returnValue =
).DateTimeFormat);
}
ex; }
ex) { EmitErrorMessage(ex.Message, ex.TargetSite.ToString(), columnName, dr.GetFieldType(dr.GetOrdinal(columnName)).ToString()); }
Hello,
When you call this.drawingsGrid.ActiveRow.Cells["Date_Created"].Value.ToString() is the same like you are get the object and call its default ToString() method. So formatting and etc. shouldn’t affect ToString() method of the actual value of the cell. I recommend you to call GetText() method of the cell. it returns the text for the object using the specified mask mode. So if you have any mask applied to the column you will get the resolved text.
http://help.infragistics.com/Help/NetAdvantage/WinForms/2011.1/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v11.1~Infragistics.Win.UltraWinGrid.UltraGridCell~GetText.html http://help.infragistics.com/Help/NetAdvantage/WinForms/2011.1/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v11.1~Infragistics.Win.UltraWinGrid.UltraGridCell~Text.html
MonthCalendar returns a DateTime value, as you said drawingsGrid.ActiveRow.Cells["Date_Created"] returns DateTime value. So simply you could get this two date and compare them.
DateTime gridDate = (DateTime) this.drawingsGrid.ActiveRow.Cells["Date_Created"].Value;
DateTime calendarDate = monthCalendar1.SelectionStart;
if(calendarDate >= gridDate)
// your code
Please try this suggestions and let me know for the result. If you compare a DateTime objects, their formatting shouldn't have any effect on the comparison operator.
Please let me know if you have any further questions or if I am missing something.
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.
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.