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 |
|
Mahathi
Starting Member
2 Posts |
Posted - 2006-07-18 : 02:49:18
|
| Hi all I have an application which takes start time from a different date. My actual requirement is "How to take start time someday in august or other month if the current day is in the month". I will be thankful to any help provided.Mahathi.Mahathi |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-07-18 : 02:59:24
|
| not sure what you mean...select dateadd(month,@months_ahead,getdate())--------------------keeping it simple... |
 |
|
|
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts |
Posted - 2006-07-18 : 05:46:15
|
This is my guess at what you mean...--datadeclare @t table (d datetime)insert @t select '20060813'union all select '20060824'union all select '20060718'union all select '20060731'union all select '20060901'union all select '20060801'--inputsdeclare @d datetimeset @d = '20060813'--demoselect dateadd(month, datediff(month, 0, @d), 0) as StartOfMonth, dateadd(month, datediff(month, 0, @d)+1, 0) as StartOfMonthAfter--calculationselect d as DatesInSameMonthOnly from @twhere d >= dateadd(month, datediff(month, 0, @d), 0) and d < dateadd(month, datediff(month, 0, @d)+1, 0) If it's not this or what jen suggested, please give us some more information - ideally with some example data (as above).Ryan Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part. |
 |
|
|
Mahathi
Starting Member
2 Posts |
Posted - 2006-07-18 : 06:01:42
|
| Thank You for the help provided Ryan. This solved my problem. Thanks a lot.Mahathi |
 |
|
|
|
|
|
|
|