?
Solved

Display all dates of current month

Posted on 2006-04-19
8
Medium Priority
?
218 Views
Last Modified: 2013-12-25
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

0
Comment
Question by:scooter41
  • 5
  • 3
8 Comments
 
LVL 27

Expert Comment

by:Nopius
ID: 16495377
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.
 
0
 
LVL 27

Expert Comment

by:Nopius
ID: 16495396
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.
0
 

Author Comment

by:scooter41
ID: 16495413
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
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 27

Expert Comment

by:Nopius
ID: 16495576
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?
0
 

Author Comment

by:scooter41
ID: 16495602
Perl, thanks for your help so far, this is starting to make clearer sense now
0
 
LVL 27

Expert Comment

by:Nopius
ID: 16495684
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;
0
 
LVL 27

Accepted Solution

by:
Nopius earned 1200 total points
ID: 16495701
oops, bugs :)
probably:
1+ ($now_time->mon+1) % 13
instead of:
($now_time->mon+1) % 12
0
 

Author Comment

by:scooter41
ID: 16495709
thanks heaps for your support, in this hour of need :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month14 days, 18 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question