The conversion of a nvarchar data type to a datetime

Rabia Kurnaz 386 Reputation points
2024-02-20T09:21:41.4+00:00

When I get a report via view, I get an error like this. how can i fix this Screenshot 2024-02-20 121825

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,786 questions
SQL Server Transact-SQL
SQL Server Transact-SQL
SQL Server: A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.Transact-SQL: A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
97 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,637 questions
{count} votes

Accepted answer
  1. Olaf Helper 44,501 Reputation points
    2024-02-20T09:35:37.7133333+00:00

    Date format like this 'dd.MM.yyyy'

    German format, use the CONVERT function with format paramater 104 = German, see https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-ver16

    select convert(datetime, '20.02.2024', 104)
    
    
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. LiHongMSFT-4306 27,016 Reputation points
    2024-02-20T09:27:53.8433333+00:00

    Hi @Rabia Kurnaz Have you checked if exists wrong date value like this: 2024-02-31.

    Best regards,

    Cosmog Hong


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.