Daily, Weekly, Monthly, Yearly

Hi,

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.

Thanks
dudupAsked:
Who is Participating?
 
2266180Connect With a Mentor Commented:
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.
0
 
KristaoConnect With a Mentor Commented:
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 :).
0
 
BlackTigerXConnect With a Mentor Commented:
"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
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
JaccoConnect With a Mentor Commented:
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
0
 
KristaoCommented:
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.
0
 
JaccoCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.