Checking how old the Account is in Months

Posted by Raj.Trivedi under Sql Server category on | Points: 40 | Views : 899
Overe here we will check how old the account is
we will pass the account number and check store the account creation date and check with the current date using the date diff function of sql

ALTER proc checkmonths
@accountno int
declare @creationdate datetime;
declare @Monthcount varchar(3);
declare @finaldate varchar(25);
declare @months varchar(3);
set @creationdate =(select accountcreationdatetime from bankinfo where accountno = @accountno)
set @finaldate= (select Convert (varchar(25),@creationdate,105))
set @months=(select datediff(month,@finaldate,getdate()))

select @months 'months'

Comments or Responses

Login to post response