I have a gridview and sqldatasource.
In tabledefinition the default format for date is mm:dd:yyyy , is there any way of changing the format to dd:mm:yyyy from sql settings or something like that.
I have globalization in form load(for dd/mm/.yyyy) but when I’m selecting from datasource some values between some dates :
string d1 = Convert.ToDateTime(date1.Text).ToString("dd.MM.yyyy");
string d2 = Convert.ToDateTime(date2.Text).ToString("dd.MM.yyyy");
SqlDataSource1.SelectCommand = "Select * FROM test WHERE Name = '"+name.Text+"' AND Date between '"+d1+"' AND '"+d2+"'";
It works only for mm/dd/yyyy.
Is there any way to change it?
Its better if you can use Parameters with the query. Also if your column type is Date, then its better if you don’t convert them to string for the comparison. Try the following
Also use parameters for Name