Reputation: 3640
I am calling a stored procedure where I'm trying to cast a number into a datetime (as I'm grabbing it from excel so it converts dates to numbers:
exec UpdateInvoices @InvoiceDate = select cast(cast(42109 as datetime) as date)
This doesn't work, I get incorrect syntax near Select.
What's the correct way of doing this?
Upvotes: 2
Views: 47
Reputation: 1064204
Just lose the select
:
exec UpdateInvoices @InvoiceDate = cast(cast(42109 as datetime) as date)
Upvotes: 1
Reputation: 1156
You need to set your parameter first.
DECLARE @DateParam date
SELECT @DateParam = cast(cast(42109 as datetime) as date)
EXEC UpdateInvoices @InvoiceDate = @DateParam
Upvotes: 1