Depending on your regional settings, the parameter you are passing in for @TimeItemAdded might not be recognized.

You should pass the date in as:

20120720
Answer from LittleBobbyTables - Au Revoir on Stack Overflow
Discussions

Error converting data type nvarchar to datetime??? – SQLServerCentral Forums
Error converting data type nvarchar to datetime??? Forum – Learn more on SQLServerCentral More on sqlservercentral.com
🌐 sqlservercentral.com
November 15, 2007
[RESOLVED]SSRS Error converting Datatype NVARCHAR to DATETIME / Too many Arguments Specified
Hey all, I'm trying to modify this existing SSRS report that our users run on a need-basis ( Link is posted on our SharePoint, they run it whenever they need to pull some order data). The report is built using a couple SPs and an Agent job. The first SP, let's call it Order_SP, builds the table ... More on forums.sqlteam.com
🌐 forums.sqlteam.com
0
0
January 20, 2016
sql - Calling stored procedure Error: Error converting data type nvarchar to datetime - Stack Overflow
Msg 8114, Level 16, State 5, Procedure PP_Sp_ObservationSchedule, Line 0 Error converting data type nvarchar to datetime. More on stackoverflow.com
🌐 stackoverflow.com
SQL Server : error converting data type nvarchar to datetime - Stack Overflow
EDIT Thank you for all your help. First thing, I have read tons of post and question of people having this same error, mines varies for int and bigint but the error stays the same, I can not inser... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Edureka Community
edureka.co › home › community › categories › database › error converting data type nvarchar to datetime...
Error converting data type nvarchar to datetime SQL Server | Edureka Community
August 15, 2022 - I encountered this error: Error converting data type nvarchar to datetime When inputting a date in ... 104) Can someone please help me with this?
🌐
SQLTeam
forums.sqlteam.com › ssas and ssrs
[RESOLVED]SSRS Error converting Datatype NVARCHAR to DATETIME / Too many Arguments Specified - SSAS and SSRS - SQLTeam.com Forums
January 20, 2016 - Hey all, I'm trying to modify this existing SSRS report that our users run on a need-basis ( Link is posted on our SharePoint, they run it whenever they need to pull some order data). The report is built using a couple SPs and an Agent job. The first SP, let's call it Order_SP, builds the table ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › archive › msdn-technet-forums › c3391f94-2928-4de2-a61e-0383f8774093
Error converting data type nvarchar to datetime | Microsoft Learn
On SQL-Server, a string such as '2012-02-29' will be parsed for a datetime as YYYY-DD-MM instead of YYYY-MM-DD when the dateformat is set to either dmy or ydm. This is because the dateformat dmy and ydm are identical on SQL-Server for the datetime type. However, this is no longer true for the more recent "date", datetime2 and datetimeoffset types.
Find elsewhere
🌐
YouTube
youtube.com › luke chaffey
Error converting data type nvarchar to datetime SQL Server - YouTube
c#: Error converting data type nvarchar to datetime SQL ServerThanks for taking the time to learn more. In this video I'll go through your question, provide ...
Published   March 13, 2023
Views   1K
Top answer
1 of 3
4

Since you are trying to pass in table name (not in your question but mentioned in the comments) you do need dynamic sql because table names cannot be parameterized. However, you can pass in the name as a parameter to your procedure just like all the values. Then you can parameterize your dynamic sql which will eliminate all the hassle of datatype conversions and such. Something like this should be pretty close. I also added a lot of white space so this is easier to read.

ALTER PROCEDURE [dbo].[myproc]
(    
    @name varchar(50)
    , @ID bigint
    , @birthdate datetime
    , @Enabled bit
    , @married bit 
    , @employees int
    , @hiredDate datetime
    , @TableName sysname
)
AS
BEGIN 
    SET NOCOUNT ON
    DECLARE @sql AS NVARCHAR(MAX)       
    SET @sql = 'IF EXISTS(SELECT * FROM ' + QUOTENAME(@TableName) + ' WHERE ID = @ID )
                     UPDATE ' + QUOTENAME(@TableName) + ' 
                     SET
                     name = @name
                    , birthdate = @birthdate
                    , Enabled = @Enabled
                    , married = @married
                    , employees = @employees
                    , hiredDate = @hiredDate
                    where ID = @ID
                ELSE
                INSERT INTO ' + QUOTENAME(@TableName) + '
                (
                    name
                    , ID
                    , birthdate
                    , Enabled
                    , married
                    , employees
                    , hiredDate
                )VALUES
                (
                    @name
                    , @ID
                    , @birthdate
                    , @Enabled
                    , @married
                    , @employees
                    , @hiredDate
                )'
EXEC sp_executesql @sql,
    N'@name varchar(50)
    , @ID bigint
    , @birthdate datetime
    , @Enabled bit
    , @married bit 
    , @employees int
    , @hiredDate datetime'
    , @name = @name 
    , @ID = @ID
    , @birthdate = @birthdate
    , @Enabled = @Enabled
    , @married = @married
    , @employees = @employees
    , @hiredDate = @hiredDate

END
2 of 3
3

There is no need for dynamic SQL at all:

ALTER PROCEDURE [dbo].[myproc]
(    
    @name varchar(50),@ID bigint,@birthdate datetime,@Enabled bit
    ,@married bit ,@employees int,@hiredDate datetime
)
AS
BEGIN 
SET NOCOUNT ON
IF EXISTS(SELECT * FROM MyTable WHERE MyTable.ID =@id)
     UPDATE MyTable
     SET name =name
        ,birthdate=@birthdate
        ,Enabled =@Enabled
        ,married=@married
        ,employees=@employees
        ,hiredDate=@hiredDate
      where ID = @ID;
 ELSE
INSERT INTO MyTable(name,ID,birthdate,Enabled,married,employees,hiredDate)
VALUES(@name, @ID, @birthdate, @Enabled, @married, @employees, @hiredDate) ;      
END

EDIT:

I run this sp with:

    @birthdate = '2018-12-10 16 45 00',

I propose to provide parameter with culture independent format ISO-8601 YYYY-MM-DDThh:mm:ss

 @birthdate = '2018-12-10T16:45:00',
🌐
SQLServerCentral
sqlservercentral.com › forums › topic › converting-from-nvarchar-to-datetime
Converting from NVarchar to DateTime – SQLServerCentral Forums
September 3, 2009 - Jeff's examples are good for dates which are in some sort of month, day, year format, which is the default. SQL will also automatically handle year, month, day, if all four digits of the year are displayed. select CAST ('03-06-10' AS DATETIME) = 2010-03-06 00:00:00.000
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1539456 › the-conversion-of-a-nvarchar-data-type-to-a-dateti
The conversion of a nvarchar data type to a datetime - Microsoft Q&A
Then use the TRY_CONVERT function, it don't raise an error on faulty data: https://learn.microsoft.com/en-us/sql/t-sql/functions/try-convert-transact-sql?view=sql-server-ver16
🌐
Stack Overflow
stackoverflow.com › questions › 48437156 › error-converting-data-type-nvarchar-to-datetime
c# - 'Error converting data type nvarchar to datetime' - Stack Overflow
It's an SQL Server error message. We need to see the SQL code. @JohnWoo - what value do you think that function call is adding to the code? ... @Shnugo - at the moment, from the C# side, everything looks right. ADO.Net (ultimately) should be receiving a DateTime value and translating it into a SQL Server datetime value.
🌐
Experts Exchange
experts-exchange.com › questions › 24491632 › Error-converting-data-type-nvarchar-to-datetime.html
Solved: Error converting data type nvarchar to datetime | Experts Exchange
June 15, 2009 - I have updated this on the my test servers to be the same but it didn't change my results I still get the same error ... Hi, EHardie are you fine?,after create (FormatDateTime) user define funcion you can use it like(snippet code) thanks. CREATE PROCEDURE [dbo].[Create_Header] @DocType int, @DebtorId char(15), @DocType2 char(6), @DocNo char(10), @InvoiceNo char(10), @Taxdate datetime, @CustPO nchar(20), @Comments nvarchar(212), @CRMCreateDateTime datetime, @CRMContractNumber varchar(20), @CRMContractRenewalId int, @CRMCompanyId int, @CRMSiteId int, @ANUID varchar(20), @ID int OUTPUT AS BEGIN S
🌐
Medium
medium.com › @python-javascript-php-html-css › how-to-fix-common-errors-when-converting-nvarchar-to-datetime-in-sql-0061ad539a94
How to Fix Common Errors When Converting NVARCHAR to DATETIME in SQL
December 24, 2024 - What should I do if my NVARCHAR data has inconsistent date formats? Implement a pre-validation script using Python’s pandas.to_datetime() or JavaScript’s Date object to standardize the format. ... Yes, use the LEFT function to truncate unwanted parts of the string before using CONVERT. How do I log errors during conversion in SQL Server?
🌐
SQL Team
sqlteam.com › forums › topic.asp
error converting data type nvarchar to datetime - SQL Server Forums
August 17, 2011 - Site Sponsored By: SQLDSC - SQL Server Desired State Configuration