querybuilder icon indicating copy to clipboard operation
querybuilder copied to clipboard

Problem with Date format in SqlServer

Open JordiPerello opened this issue 5 years ago • 2 comments

When we have fields of type Date, the SqlKata.Compile() converts it to the format "YYYY-DD-MM" instead of "YYYY-MM-DD", depending on the configuration of your DB, this causes an error when executing the SqlServer statement

I think it is important to work with the culture or in any case work with ISO-8601, which does not care about the configuration that we have in our database, since it is a standard format that any SqlServer recognizes without problems, instead of "YYYY-MM-DD", we removed the scripts and it would be"YYYYMMDD", this is enough to stop giving problems in any query.

There is an email that I have sent to Ahmad Moussawi, in which I explain the problem with examples and images.

Please, I hope you can find the problem, because at the moment this causes us errors in our application and we have to do special processes to solve it and we have a bad code

Thanks, I think you're doing a great job with this framework

JordiPerello avatar Mar 08 '19 09:03 JordiPerello

Maybe providing input formatters can solve this, something like:

db.Format(typeof(DateTime), (value) => value.ToString("yyyyMMdd"));
db.Format(typeof(int), (value) => value.ToString("N3"));

ahmad-moussawi avatar Mar 19 '19 09:03 ahmad-moussawi

same case here!, would be a great enhancement could provide a serie of format providers or even setting some type of configuration in order to inform to the Compiler class wich is the target configuration, for example in the explicit SqlServerCompiler instanciation.

rolivares avatar Jul 22 '22 22:07 rolivares