I had this problem with dates with "ever"
I live in a country where we use British date formats, for example. dd / mm / yyyy, but every time I try to execute a query to sql db hosted on an American server, 100% of the time when I come up with errors.
Convert.ToDateTime("2007-17-5")throws an error, where as Convert.ToDateTime("2007-5-17")also produces an error.
Many validation methods, many t-sql queries, and many other methods that I tried to partially solve in most of my projects, however, I would like to know if anyone has a universal way to convert strings to a date when it does not cause any problems?
or any good resources for working with dates?
----------- editing ... -----------------
even if I format the dates correctly, the query to the sql server does not give any value, even if I'm sure that there is .. for example .. if I look for entries related to dates between 1/1/2009 (i.e. January 1, 2009) until 1/5/2009 (this is May 1, 2009), entries are not returned. And when I try to change the date in the sql server query builder, it gives me an error saying this is not a valid date that I entered ...
source
share