sp_executesql with datetime output parameter I'm facing a problem here in SQL Server. I have to use the stored procedure sp_executesql that is a system procedure, because the table on which I do my select clause depends on an other parameter.
Here is the sample : 
@p_Origin is a parameter that is given in my procedure, so to reproduce the problem let's declare it like this : 
DECLARE @p_Origin nvarchar(255) = 'Sales'

I also have one parameter in my SELECT clause, that are columns of the target table :
DECLARE @v_valueVersion as int 
IF @p_Origin = 'Sales'  
    SET @v_valueVersion = (SELECT VersionId FROM Version WHERE ...)
ELSE IF 
    ...

But now, I want to get back a column from my origin table, (which is Sales here)
With this query : 
DECLARE @v_query as nvarchar(max) = 'SELECT MAX(Date) FROM dbo.' + @p_Origin + ' WHERE VersionId = ' + CAST(@v_valueVersion as nvarchar) + ' AND Month = CONVERT(NVARCHAR(6),GETDATE(),112) '

This column, date, is a datetime column, declared here : (Month column and date column are two different things, and they don't refer the same period)
DECLARE @v_maxDate as datetime  

And here is my problem : 
EXEC sp_executesql @v_query, N'@v_maxDate datetime out', @v_maxDate out

When I get this, the SELECT clause give me the following result, which is the good one : 

2016-01-19 15:49:58.000

But When I PRINT the value, nothing is printed, and the value is null. How can I get back some datetime value with this stored procedure ? Is it even possible ? 
EDIT : as Adwaenyth said  bellow, the following query works perfectly : 
DECLARE @query nvarchar(max) = 'SELECT  @v_maxDate = MAX(create_date) FROM sys.tables'
DECLARE @v_maxDate datetime

EXEC sp_executesql @query, N'@v_maxDate datetime out', @v_maxDate out

PRINT @v_maxDate

Is it possible that the fact that I use several variables in my query modifies the result ? 

Change your query to
DECLARE @v_query as nvarchar(max) = 'SELECT @v_maxDate = MAX(DATE) FROM dbo.' + @p_Origin + ' WHERE VersionId = ' + CAST(@v_valueVersion as nvarchar) + ' AND Month = CONVERT(NVARCHAR(6),GETDATE(),112) '

and it should work.
/edit: just tried it myself with this ad-hoc query and it worked perfectly:
DECLARE @query nvarchar(max) = 'SELECT  @v_maxDate = MAX(create_date) FROM sys.tables'
DECLARE @v_maxDate datetime

EXEC sp_executesql @query, N'@v_maxDate datetime out', @v_maxDate out

PRINT @v_maxDate

Exactly printed the output:

Jan 18 2016  1:10PM

Perhaps try to run the query above and see if that runs on your server... if it does, maybe look at the syntax of your query again.

Thanks a lot for this info. I had the same problem, and this helped me solve it.
Here's my understanding:  When using sp_executesql to assign the result of a query to a variable, the variable must be part of the query itself. That is, it doesn't work to (conceptually) run the query in Step 1 ({query} = "SELECT Max(Date) FROM {table}...") and then, in Step 2, to assign the output to a variable (e.g., sp_executesql {query}, @varOut OUTPUT). This is what the OP was doing at first, and it also was my original approach. Instead, the query itself must assign the result to the variable in one step:  "SELECT @varOut = Max(Date) FROM {table}..."
It seems that the first approach runs the query in the "normal" way (i.e., as if it were manually typed at the command line) and therefore sends the results to STDOUT as normal. This makes Max(Date) visible on screen, as the OP could see. But the output doesn't get assigned to the variable. Instead, sp_exectuesql must have some kind of success/failure indication that it returns by default. This is what the OP saw when printing the value of @varOut.
Thanks again for the help.