Date's problem RRS feed

  • Question

  • Hi all

    My name is George, coming from Greece

    I am use the SQL SERVER 2012, and i am developing a project in Visual Basic 2013.

    In my computer, and in the others that execute my project, the system is

    set to my country settings for dates and numbers. That means a date it is

    look "d/M/yyyy" ( e.g. 25/6/2019 or 4/6/2019 means 25 June 2019 or 4 June 2019).

    When i write a date in my SQL Database, it is wrote like 2019-06-25 or 2019-06-04.

    If i have the system settings to my country settings when i read a date from the Database

    and do some comparisons with dates, i receive an run-time error that the date it is not to correct format.

    If i have change the system settings to English (USA), i am not receive any error when doing

    dates comparisons.

    I don't want to change my system settings, i want to have my country settings, because my documents,

    my spreadsheets i want to show the dates in the format of my country.

    How i can resolve this problem?

    Thanks in advance, and i am sorry for my English.

    Monday, July 1, 2019 9:26 AM

All replies

  • Since we don't see your code, we can't tell what you are doing wrong. However, you should always work with dates so that you are not depending on a particular format. For instance, when passing dates to SQL Server from the client, they should always be passed as parameters with the Date data type. You should never inline the dates into the query as a constant - nor should you do that with any other input value for that matter.

    Erland Sommarskog, SQL Server MVP,

    Monday, July 1, 2019 10:02 PM