Jump to content

SQL interaction giving me a headache


jhecht
 Share

Recommended Posts

So as of late I've been attempting to get a calendar up and going in order to help out a club at the college I go to. I can get the calendar to be displayed, but the issue comes in at the type of database structure to be used. This was my first thought on creating the database structure:

event_id INT UNIQUE NOT NULL AUTO_INCREMENT,event_title varchar(255) not null,event_start bigint not null,event_end bigint not null,event_all_day tinyint not null default 0,event_repeat_increment bigint not null

My only problem with this method comes in on how I am supposed to determine if a timestamp of an entry is related to the timestamp we are working with.For example, assume we made a 5 hour long event that repeats every two weeks on the exact Unix Epoch. the event_start would be 0, event_end would be 18000(60*60*5), and the event_repeat_increment would be 1209600(60*60*24*7*2, where 2 is the number of weeks).Let's say we are 2 weeks later. i know the formula to calculate the start time of the event is new_start_time = [original start time] +x(repeat_increment). x can only be whole number iterations, so things like 1,2,3,4,5,6,etc. if you solve for x that gives you (new_start_time-original_start_time)/repeat_increment = x. None of this, however, gives me an answer as to how to pull results in a repeating fashion.I'm seriously lost, and if anyone could offer me any outside insight on this, I'd greatly appreciate it.Thanks,-Jhecht

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...