Insert date time from other culture to SQL Server us_english
1) To know which language is in use. @@Language
select
2) To know all languages
sp_helplanguage
3) For set new language :
SET
4) For set new dateformat.
SET dateformat dmy
Now set the format and
dateTime.ToString("MM/dd/yyyy", dateTimeFormat);DateTimeFormatInfo dateTimeFormat = (new CultureInfo("??-??")).DateTimeFormat; LANGUAGE us_englishhttp://www.sql-server-helper.com/tips/date-formats.aspx
2Nd:-
Set DD MM YYYY from C#
string dateFormat = "dd-MM-yyyy";
string Dtfrm = dateFrom.ToString(dateFormat);
Use in inline query with convert function
"date_from >= CONVERT(DATETIME,'" + Dtfrm + "',105) "
For example you can check following function in SQL and give correct result.
105
select CONVERT(DATETIME,'18.08.2010',105)
select CONVERT(DATETIME,'18-08-2010',105)
select CONVERT(DATETIME,'18/08/2010',105)
Thanks
Mahesh
1) To know which language is in use. @@Language
select
2) To know all languages
sp_helplanguage
3) For set new language :
SET
4) For set new dateformat.
SET dateformat dmy
Now set the format and
dateTime.ToString("MM/dd/yyyy", dateTimeFormat);DateTimeFormatInfo dateTimeFormat = (new CultureInfo("??-??")).DateTimeFormat; LANGUAGE us_englishhttp://www.sql-server-helper.com/tips/date-formats.aspx
2Nd:-
Set DD MM YYYY from C#
string dateFormat = "dd-MM-yyyy";
string Dtfrm = dateFrom.ToString(dateFormat);
Use in inline query with convert function
"date_from >= CONVERT(DATETIME,'" + Dtfrm + "',105) "
For example you can check following function in SQL and give correct result.
105
select CONVERT(DATETIME,'18.08.2010',105)
select CONVERT(DATETIME,'18-08-2010',105)
select CONVERT(DATETIME,'18/08/2010',105)
Thanks
Mahesh
No comments:
Post a Comment