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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Start Date From

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...
Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2006-07-18 : 05:46:15
This is my guess at what you mean...

--data
declare @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'

--inputs
declare @d datetime
set @d = '20060813'

--demo
select dateadd(month, datediff(month, 0, @d), 0) as StartOfMonth,
dateadd(month, datediff(month, 0, @d)+1, 0) as StartOfMonthAfter

--calculation
select d as DatesInSameMonthOnly from @t
where 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 Randall
www.monsoonmalabar.com London-based IT consultancy

Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

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
Go to Top of Page
   

- Advertisement -