Pages

Monday, September 21, 2009

Save a datetime into SQL Server 2005 in dd/MM/yyyy format By Praveen P.R

y//C#
//Save datetime in dd/MM/yyy formate into DataBase

//While Insert statement
e.g
Insert into ....purchaseDate="'+ DateTime.ParseExact(dateTimeField.Value.ToString("dd/MM/yyyy"), "dd/MM/yyyy", CultureInfo.InvariantCulture.DateTimeFormat)+"' .....;

//While Select statement
 e.g
Select
convert(datetime,purchaseDate,103) =convert(datetime,'" + DateTime.ParseExact(dateTimeField.Value.ToString("dd/MM/yyyy"), "dd/MM/yyyy", CultureInfo.InvariantCulture.DateTimeFormat) + "',103) ,.........from tablename

http://www.prpraveen.blogspot.com

No comments: