February 12, 2013 at 12:31 pm
I need to get the first day of the followingmonth.How is it possible.I am unable to find a way to proceed
i.e my output should be like this
Scenario 1:
Input-2012/01/29
Output-2012/02/01
Scenario 2:
Input-2012/12/29
output-2013/01/01
I need to accumlate both the scenarios in same coding
Please guide me in solving this.
Thanks in advance
February 12, 2013 at 12:41 pm
I can't really see what this has to do with SSIS, but here's one way.
declare @MyDate datetime
set @MyDate = '2012-12-29'
select DATEADD(dd, - (DAY(DATEADD(mm, 1, @MyDate )) - 1), DATEADD(mm, 1, @MyDate ))
February 12, 2013 at 12:45 pm
Here is an example query to do it
Declare @day date
set @day = '2012/01/29'
select @day
Select DAY(@day) as Noofdays
SELECT DATEADD(mm,1,DATEADD(dd,-(DAY(@day)-1),@day)) AS Day
Select DATEADD(yy,1,DATEADD(dd,-(DAY(@day)-1),@day)) as Day
February 12, 2013 at 12:48 pm
Using T-SQL:
declare @MyDate datetime;
set @MyDate = '20121229';
select dateadd(mm, datediff(mm,cast('19000101' as datetime),@MyDate) + 1, cast('19000101' as datetime)), @MyDate;
February 12, 2013 at 1:40 pm
I have to work on SSIS to get the first day of following month and the output should be as string value.
Input:getdate()
Output:Firstday of the following month
format of output is=yyyymmdd
Sorry for not providing the perfect information in the previous post.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy