Daily, Weekly, Monthly, Yearly

Posted on 2006-05-05
Medium Priority
Last Modified: 2010-04-05

What is the best way to create a procedure that will perform a task daily, weekly, monthly and yearly ?

I assume that daily will be performed right after midnight, weekly will be performed on monday morning after sunday midnight, monthly will be performed after end of month, yearly will be performed after end of december.

Question by:dudup
LVL 28

Accepted Solution

2266180 earned 164 total points
ID: 16614538
actually, there are a lot of ways to make recurrent events (tasks). maybe the best way is to look in an applicaiton such as MS outlook or another one that supports recurring events/tasks. you can see there all or most of the combinations.
as a timeframe, it mostly depends on the user, so I would let him configure at what hour he whishes the recurrence to take place. by default you should probably use the midnight reference.
for weekly, keep in mind that in some areas, the week starts with sunday and in otehr with monday.

Assisted Solution

Kristao earned 152 total points
ID: 16615230
Its easy M'Kay

In delphi you will find DateUtils routines

every task needs starting point so you need to check days, minutes, month betwen task was fired perviosly.

so with DateUtils you can scale tasks even every 5 secundes :).

So lets supose your minumum task interval is 5 min. So after every 5 minutes just fire procedure and chack how many days are between last event was fired. You need some litle database. In this case u could use kmemtable component its for free open source :).
LVL 13

Assisted Solution

BlackTigerX earned 152 total points
ID: 16618799
"I assume that daily will be performed right after midnight, weekly will be performed on monday morning after sunday midnight, monthly will be performed after end of month, yearly will be performed after end of december."

don't assume anything, just give the option "start date/time" (and while you're at it Stop date/time too)

and you can make it periodically from that time on
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

LVL 10

Assisted Solution

Jacco earned 152 total points
ID: 16620252
Hi Dudup,

In windows control panel there is a "Scheduled Tasks" icon. You can schedule the execution of your Delphi application there daily, weekly and monthly at specified times. In XP there is no options to schedule such a task yearly, but actually you only have to schedule one daily task at 0:00 hour and check inisde the procedure if it also is the end of a week/month/year.

This is a very reliable manner because if Windows is running you are sure the scheduled task gets fired and you are not dependant of any other app (that might not be running) to fire it.

Regards Jacco

Expert Comment

ID: 16620732
Shedule Task using othere App to run yours App? Can't see sence in there. This app what is needed to be created is easy as Calculator.

put a timer on form and check the time every second if the time is biger than 00:00 thats meens you need to check daily tasks and check isn't there end of week or end of month or end of year.

if DayOf(Now)= 1 then check weekly tasks
if MonthOf(Now)=1 then check yearly tasks

an so on.
LVL 10

Expert Comment

ID: 16701560
Schedule Tasks is integrated inside Windows some service of the operating system takes care of running your apps when you want it.

There is no application with a higher up-time then the operating system so why not use it to run your app.

The self written app does not have to stay up this way for more than a year. It just needs to get fired up by the operating system.

Regards Jacco

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month16 days, 23 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question