April 5, 2005 at 5:38 pm
Hi Expert,
Please help, I'm stuck with this.
If the current date is 04/15/05, I want to set my date to 4/30/05
If the current date is 05/31/05, I want to set my date to 6/15/05.
Please advice. Thanks a million.
Minh
April 5, 2005 at 5:45 pm
Can you explain the business rules a bit more? ie: what has to happen if the current date is 04/20/05 ??
--------------------
Colt 45 - the original point and click interface
April 5, 2005 at 7:17 pm
We always process the payment on 15 or end of the month. Therefore, my data always stable and there is always no exception. Thanks
Minh Vu
April 5, 2005 at 7:22 pm
That's still pretty vague.
Is this date stored somewhere and you want to change it after you've performed the processing??
--------------------
Colt 45 - the original point and click interface
April 6, 2005 at 1:27 am
my 2ct (not knowing the exact buisiness rrule)
select case when day(getdate()) > 14 then
DATEADD(d, -1, DATEADD(m, 1 + DATEDIFF(m, 0, getdate()), 0))
else
convert(datetime,cast(year(getdate()) as char(4)) + '-' + cast(month(dateadd(m,1,getdate())) as char(2)) + '-' + '15', 121)
end as paymentdate
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
April 6, 2005 at 2:53 am
Piggy-backing on alzdba, what about this?
SELECT
CASE
WHEN DAY(GETDATE()) > 14
THEN DATEADD(mm,1,DATEADD(DAY,1-DAY(GETDATE()),DATEDIFF(d,0,GETDATE())))-1
ELSE DATEADD(mm,1,DATEADD(DAY,15-DAY(GETDATE()),DATEDIFF(d,0,GETDATE())))
END
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
April 6, 2005 at 3:51 pm
Thanks a lot Frank.
That is exactly what I need.
Minh vu
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply