Daily, Weekly, Monthly, Yearly

Posted on 2006-05-05
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

    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.
    LVL 1

    Assisted Solution

    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

    "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
    LVL 10

    Assisted Solution

    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
    LVL 1

    Expert Comment

    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

    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
    Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now