trying to get date difference after date in php

I have a mySQL database that has a starttime field (datetime), endtime field (datetime), coursecode field (GPR4 for example) and a nice pretty field that has the dates already formatted like December 28-30, 2006.

The database is a listing of all available events occuring at our facility. I am displaying the available dates on the web. I figured I'd make it easy on myself and use the pre-formatted field BUT I forgot something. We have a course called GPR3 and GPR4 (the 3 and 4 refering to a 3 and 4 day course). The GPR3 dates are all GPR3 and GPR4 dates (they just do the first 3 days). So when I select all the info with rows containing both coursecodes, the nice and pretty pre-formatted column still shows the course running 4 days.

I have a mySQL database that has a starttime field (datetime), endtime field (datetime), coursecode field (GPR4 for example) and a nice pretty field that has the dates already formatted like December 28-30, 2006.

The database is a listing of all available events occuring at our facility. I am displaying the available dates on the web. I figured I'd make it easy on myself and use the pre-formatted field BUT I forgot something. We have a course called GPR3 and GPR4 (the 3 and 4 refering to a 3 and 4 day course). The GPR3 dates are all GPR3 and GPR4 dates (they just do the first 3 days). So when I select all the info with rows containing both coursecodes, the nice and pretty pre-formatted column still shows the course running 4 days.

So my output is looking like this.

Available GPR3 dates:May 22-25, 2006June 5-8, 2006June 19-22, 2006June 26-28, 2006July 5-7, 2006July 10-13, 2006As you can see, most of the dates are GPR4 dates and therefore show the course running 4 days.

So how should I go about fixing this. The startdate field returns format YYYY-MM-DD 00:00:00.

The logic basically needs to go

if(enddate - startdate > 3) { enddate--;}

And then I can work with it from there. I'm just lost as to what transformations (and how) to do on the datetime format from sql to get there.

Thanks in advance for all help!!![/quote]

I dont know exactly what you are trying to do. If all it is is to get two different sets of dates, one the GPR4 and one the GPR3.. all you need to do is two diff queries..

//$coursecode is the GPR variable.. so if you create a form to pull up the dates you will use 'coursecode' as the name of the input field.. ex.

I am getting a variable such as January 24-27, 2006 fed to me from mySQL, but sometimes I will need to subtract one day from the end making it January 24-26, 2006. I also have available to me the start date and end date in datetime format such as 2006-01-24 00:00:00.

How about this. How can I do math on two dates formatted in mysql datetime in PHP?

I am getting a variable such as January 24-27, 2006 fed to me from mySQL, but sometimes I will need to subtract one day from the end making it January 24-26, 2006. I also have available to me the start date and end date in datetime format such as 2006-01-24 00:00:00.

How about this. How can I do math on two dates formatted in mysql datetime in PHP?[/quote]

ahhh good question

here is some code i was working with just a few weeks agao.. hopefully it is displayed nice.. anyways its exactly what you want. just assign $date_today variable the variable that you are retrieving from your database.. and where i use 6 days, you would use 1 in your case... its a pretty nifty snipplet of code

here is some code i was working with just a few weeks agao.. hopefully it is displayed nice.. anyways its exactly what you want. just assign $date_today variable the variable that you are retrieving from your database.. and where i use 6 days, you would use 1 in your case... its a pretty nifty snipplet of code

you will notice that the way i had it i used subtraction.. you can use addition to add and get future dates, etc.. the only reason taht it needs to go to the unix timestamp is so it can get the exact time in seconds... then subtract how ever many days in seconds.. if you really look at it it should be self explanitory. hope that helps!