Answer the question
In order to leave comments, you need to log in
Why does MS SQL format dates differently?
MS SQL Server 2014
There is a table in which some dates are written in the format: 2017-11-01
There is some code with which I make a data selection (including these dates).
The question is this: if I execute the code on the same machine where the SQL server is installed, then the dates come to me in the format: 01.11.2017
That is, they are converted.
And if I execute the code on another machine, then the dates come in the original format, that is, the 2017-11-01
code is simple. Such an example:
FSQL := 'select f.sdu as StartDate from tableName f';
with Connect.SQLSelect(FSQL) do
begin
FLD_DS := Fields.FieldByName('StartDate');
while not eof do
begin
//Операторы
Next;
end;
end;
Answer the question
In order to leave comments, you need to log in
If you need to receive in a single format, just pass the culture(third) format to format, for example, for the 11/01/2017 format like this:SELECT FORMAT( GETDATE(), 'd', 'ru-RU');
I used to do something like this:
And further dismantled already means of language.
In the database itself, the field type was "datetime"
You can also force the locale in the request. At one time, it was convenient to switch to the RU locale when generating HTML files with understandable dates, and then switch back to English.
TDateTimeField.DisplayFormat Property .
CONVERT: date and time styles .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question