⌘BABAKOV.NET Let's code!
100% [light] [ru]

Way to set date in MSSQL to be independent of server regional settings.

Here is an example of how you can make a script in MSSQL work correctly with dates regardless of regional settings and date format. I personally implemented it in the following way:

In the script, write the date as follows:

convert(datetime,\'"+data+"\',120)

Where data is a string of the following type:

ГГГГ.ММ.ДД чч:мм:сс

- This is the format of the date indicated by the number 120. Therefore, the server will not confuse the month with the day, etc.

To quickly and accurately set the current date, you can use the following function:

{ fn NOW() }

That's it.

Comments (0)

No comments yet.

Leave a comment
Comment
Images (up to 5 MB)
Your comment will appear after moderation.