Jump to content


This topic is now archived and is closed to further replies.


Date range help?

Recommended Posts

I'm working on an employee leave system. My script is pulling [b]all[/b] leave incidents, but I only want it to pull the last six months.
Here's the code where it plugs the leave items:

echo $RESULT['Lmo']; 
echo "/";
echo $RESULT['Lda'];
echo "/";
echo $RESULT['LYR'];

(Leave month, Leave day, Leave year).

I also set a variable called....

..which combines the above three into "08112006" format.

...and another one called $pastdate which pulls the date on today's date six months ago.

If I use...
WHERE ('$currentdate' >= '$pastdate')

or IF


or anything else I've tried, it either bombs or returns nothing.

I want to show records from six months ago through the present.


Share this post

Link to post
Share on other sites
To compare dates you need the date elements in Y M D sequence.

MySQL and other DBMS have things called DATE fields. If you use these you have dozens of date functions at your disposal. IF you invent other ways to store dates then you have to invent ways to do the calculations them.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.