Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ismailc
Constraint Violating Yak Guru
290 Posts |
Posted - 2011-02-03 : 04:13:13
|
Good Day,I have a SSIS String Variable: PeriodIn my query i have to determine the next month period with date ranging between the 5th & 7th of the next period from Var:PeriodVar:Period = 2010.12I need to range on dates being 05/01/2011 and 07/01/2011Please Assist |
|
matty
Posting Yak Master
161 Posts |
Posted - 2011-02-03 : 04:25:10
|
Is this what you want?declare @p varchar(20)set @p = '2010.12'select @p = CONVERT(datetime,@p + '.01')select DATEADD(m,5,@p) AS StartDate,DATEADD(mm,7,@p) AS EndDate |
 |
|
ismailc
Constraint Violating Yak Guru
290 Posts |
Posted - 2011-02-03 : 04:45:29
|
Thank You, I get the result i'm looking for but it does not work to well when Var:Period changesset @p = '2010.12'result: 2011-05-01 00:00:00.000 & 2011-07-01 00:00:00.000set @p = '2011.01'result: 2011-06-01 00:00:00.000 & 2011-08-01 00:00:00.000Should not only be for 2010.12 but for any month, not to sure about the adding of the '.01'? |
 |
|
ismailc
Constraint Violating Yak Guru
290 Posts |
Posted - 2011-02-03 : 06:08:42
|
Thank You Very Much, i got it going by adding daydeclare @p varchar(20)set @p = '2010.12'select @p = CONVERT(datetime,@p + '.01')select DATEADD(day,4,DATEADD(month,1,@p)) AS StartDate,DATEADD(day,11,DATEADD(month,1,@p)) AS EndDate |
 |
|
matty
Posting Yak Master
161 Posts |
Posted - 2011-02-03 : 06:12:14
|
What should be the date range when Var:Period is 2011.01? |
 |
|
|
|
|
|
|