Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I track a repeating calendar event in C# / SQL Server? [closed]

I'd like to display a repeating event on a date/time display in an app. This date time display can take the form of a calendar, but it could also just be a list of upcoming events.

What is the best way to handle tracking this event that can repeat?

For example: Should the event be stored once in the database and projected out / repeated several times in the display code? Should the event be stored several times and then just rendered?

like image 551
Dan Esparza Avatar asked Dec 10 '08 21:12

Dan Esparza


2 Answers

I did something like this before and I based my schema off of SQL Servers sysschedules table.

http://technet.microsoft.com/en-us/library/ms178644.aspx

The schema linked above will allow you to store the schedule for a job (event). Then you can calculate what dates the event occurs on based off of the schedule. This may be a lengthy calculation, so I would try to cache that result somewhere.

like image 124
Bob Avatar answered Sep 22 '22 06:09

Bob


I think it depends on type of event it is. Is it like Christmas where once it comes along and happens you really aren't interested in it until the next occurrence? Or is it a task like, "Make sure I call my mom every month", where if it happens and you missed it you wouldn't want it to go away?

One way I recently implemented the latter was to have a record that had next_occurrence (date), reoccurence_period (weekly, monthly, yearly, etc) columns. So that as the next occurence approched it would show up in the list. Once it passed the list item would have a recycle icon that once pressed would update the record to the next future occurence.

Again, i'm not sure if this applies to your situation, but it worked well for mine.

like image 26
Jamal Hansen Avatar answered Sep 26 '22 06:09

Jamal Hansen