-3
I wonder how I do:
I want a variable like days
then take the result of this variable and select between the dates counting the number of days
Some solution or example?
-3
I wonder how I do:
I want a variable like days
then take the result of this variable and select between the dates counting the number of days
Some solution or example?
2
I don’t quite understand, but if you want to make a trial, try it this way.
declare @primeira_data datetime, @segunda_data datetime, @result int;
set @result:= Day(@primeira_data) - Day(@segunda_data);
There is a function that does this for you
DATEDIFF ( datepart , startdate , enddate )
https://docs.microsoft.com/pt-br/sql/t-sql/functions/datediff-transact-sql?view=sql-server-2017
only remove : (colon) sql server does not accept this.
Browser other questions tagged sql database sql-server
You are not signed in. Login or sign up in order to post.
Felipe: (1) You want it or you got it a variable of type days? (2) Add information in the body of your question: tables, columns, sample data etc.
– José Diz