Link to home
Start Free TrialLog in
Avatar of scooter41
scooter41

asked on

Display all dates of current month

Hi There,

I have a current mysql database, with a registered date field.

What my client wants to do is to display the current dates of this month, and display the date in bold if it is the registered date.

So for example:

April

01, 02, 03, 04, 05, 06, 07,<b> 08 </b>, 09, 10, 11, ..... 31

So I guess it would need to just loop through the dates of this month (28, 30, or 31 : month dependent)  and just check on each loop if it = registered date

Avatar of Arty K
Arty K
Flag of Kazakhstan image

Only February has flexible boundary. For any other month you may use an array of last dates.
For February you may always use 29
OR
if you like things to be more complex, substract 1-Mar from 1-Feb and get number of days of current year.
 
Also it's more effective to create an array of days of the month (from 1 to 31),
then select entire month,
then do loop for registered dates (record-by-record) and set "<b>" "</b>" in appropriate array position,
then output from 1 to the last day of your month.
Avatar of scooter41
scooter41

ASKER

I like the idea of the array, then loop, is there an easy way to get the current number of days in the current month..... in perhaps cgi or is it best to do in a mysql statement
current number of days in the current month is better to be calculated in CGI.
So you don't need extra SQL requests just for data, that can be calculated locally.
What language are you using?
Perl, thanks for your help so far, this is starting to make clearer sense now
I'm not a perl guru, but something like this:

use Time::Local;
$now_time=gmtime();
$next_month=timegm(0,0,0,1,($now_time->mon+1) % 12, $now_time->year + (($now_time->mon+1)/12) );
$this_month=timegm(0,0,0,1,$now_time->mon,$now_time->year);
$days_between=($next_month-$this_month)/60/60/24;
ASKER CERTIFIED SOLUTION
Avatar of Arty K
Arty K
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks heaps for your support, in this hour of need :)