October 10, 2007 at 6:02 am
I want to generate a alert or rather insert a record into a table based on a frequency. The frequency could be year, month or week. Eg I want to generate a alert every three month on the first day of a fourth week. How do I calculate the date?
Thanks
Ravi
October 10, 2007 at 6:19 am
I don't see any question about T-SQL.
_____________
Code for TallyGenerator
October 10, 2007 at 6:26 am
My apologies for the ambiguity, I want to calculate the date associated with 3 day of 3 week of next month. If Sunday is taken as Date First it would be 11/13/2007. This needs to be calculated dynamically based on the frequency. It could I want to know the next date from the current date which is sixth day of fourth week .
October 10, 2007 at 6:29 am
Sorry, but that just confused me even more...:w00t:
______________________________________________________________________
Personal Motto: Why push the envelope when you can just open it?
If you follow the direction given HERE[/url] you'll likely increase the number and quality of responses you get to your question.
Jason L. SelburgOctober 10, 2007 at 6:34 am
SQL Server is a Relational Database Management System. It has many powerful features that help in administering complex databases. Although we can write many programs in it, it has limitations on what it can help us to do.
There are many tools available to the IT professional, just as there are to a doctor. The trick is to know which tool will work in which situation. The example you give belongs to the realm of programming, where scheduling, timing, frequency and interval can be controlled by the programmer.
I am pretty sure your problem can be solved easily in Visual Basic.
October 10, 2007 at 6:44 am
I want to calculate the date associated with 3 day of 3 week of next month. If Sunday is taken as Date First it would be 11/13/2007. This needs to be calculated dynamically based on the frequency. It could I want to know the next date from the current date which is sixth day of fourth week .
Sorry for the cross-post. Your clarification changes the problem definition. I don't have the time right now to test my limited T-SQL to find the right code but I am sure it is doable.
October 10, 2007 at 6:49 am
Ravi
Have a go yourself and post back with what you come up with - then we can see if we can help you further. Here's a hint: look up DATEADD, DATEDIFF, DATEPART and @@DATEFIRST in Books Online. Alternatively, you may consider solving this by creating a permanent table of dates. There's plenty about that on this site.
Good luck
John
October 10, 2007 at 6:57 am
Also - you are going to want to be clear about whether "3rd week"="3rd FULL week" or not.
There was a recent editorial on here about cool things you could do with the date functions. I'd suggest you find it - should point you in the right direction.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply