I want to pass a string sample '02/01/2015' or any day of that month and get the following.
@enddate should return '03/01/2015' (the beginning of next month)
@month should return '02'
@year should return '2015'
Declare @EndDate as varchar(12)declare @month as varchar(2)declare @year as varchar(4)Set @EndDate = @startdate > should be '03/01/2015' (the first day of next month)Set @Month = @startdate > should be '02'Set @Year = @startdate > should be '2015'select @enddateselect @month select @yearselect MONTH('02/01/2015') < how can I return '02' instead of '2'select YEAR('02/01/2015') < this is ok '2015'
There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.
It is fine. I am just test a small tmp table.
How about Month something like this ?
'0' + convert(char(10), DATEPART(MM, @startdate)) > I want it to return 02 instead of 2
0
VBdotnet2005Author Commented:
The beginning of next month '03/01/2015', not the first day of the month that is passing.
Open in new window