Hi!
Please help me to understand this scenario:
For sending a pass through query from Access to SQL-server I have a function to "convert" Access date
Function DateTimeForSQL(dteDate) As String
DateTimeForSQL = "'" & Format(CDate(dteDate), "yyyy-dd-mm h:nn:ss") & "'"
End Function
the result is for example: '2014-31-03 0:00:00'
When I send "EXEC spMyQry '2014-31-03 0:00:00'" to the server it returns the correct data.
In the SP on the server I tried both types of variable declaration:
@MyDate nvarchar(21) and in another trial
@MyDate datetime
When I try to execute
"EXEC spMyQry '2014-31-03 0:00:00'" direct on the server I get an error
"The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value." when @MyDate nvarchar(21)
or
"Error converting data type varchar to datetime." with
@MyDate datetime
But BOTH definitions work when sending "EXEC spMyQry '2014-31-03 0:00:00'" from Access.
But I get an error in Access when I modify my function to
DateTimeForSQL = "'" & Format(CDate(dteDate), "yyyy-mm-dd h:nn:ss") & "'"
although this gives '2014-03-31 0:00:00'
Any idea, why a sql-string from Access cannot be taken 1:1 into SQL-server?
Thanks
Michael
Please help me to understand this scenario:
For sending a pass through query from Access to SQL-server I have a function to "convert" Access date
Function DateTimeForSQL(dteDate) As String
DateTimeForSQL = "'" & Format(CDate(dteDate), "yyyy-dd-mm h:nn:ss") & "'"
End Function
the result is for example: '2014-31-03 0:00:00'
When I send "EXEC spMyQry '2014-31-03 0:00:00'" to the server it returns the correct data.
In the SP on the server I tried both types of variable declaration:
@MyDate nvarchar(21) and in another trial
@MyDate datetime
When I try to execute
"EXEC spMyQry '2014-31-03 0:00:00'" direct on the server I get an error
"The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value." when @MyDate nvarchar(21)
or
"Error converting data type varchar to datetime." with
@MyDate datetime
But BOTH definitions work when sending "EXEC spMyQry '2014-31-03 0:00:00'" from Access.
But I get an error in Access when I modify my function to
DateTimeForSQL = "'" & Format(CDate(dteDate), "yyyy-mm-dd h:nn:ss") & "'"
although this gives '2014-03-31 0:00:00'
Any idea, why a sql-string from Access cannot be taken 1:1 into SQL-server?
Thanks
Michael