473,226 Members | 1,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

Create a 3,6,9 and 12 monthly schedule

Hello,

In MYSQL would like to produce a field for 3,6,9 or 12 months just
containing the dates of every 7 days from the current date. I think I
need a mixture of PHP and MYSQL to achieve this.

Looked all over and can't find a sausage.

Darren

Sep 20 '05 #1
4 1419
I noticed that Message-ID:
<11**********************@g43g2000cwa.googlegroups .com> from bigfella
contained the following:
In MYSQL would like to produce a field for 3,6,9 or 12 months just
containing the dates of every 7 days from the current date. I think I
need a mixture of PHP and MYSQL to achieve this.


Check out mktime()

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Sep 20 '05 #2
NC
bigfella wrote:

In MYSQL would like to produce a field for 3,6,9 or 12 months just
containing the dates of every 7 days from the current date.


$months = 3; // or 6, or 9, or 12
$now = time();
$day = $now + 7*24*60*60;
$cutoff = strtotime("+$months months");
while ($day <= $cutoff) {
$date = date('Y-m-d', $day);
$insert = "INSERT INTO the_table SET date='$date'";
mysql_query($insert);
$day = $day + 7*24*60*60;
}

Cheers,
NC

Sep 20 '05 #3
Thank-you so much NC,

could this be changed to produce a straight 31 days?

Darren

Sep 22 '05 #4
NC
bigfella wrote:

could this be changed to produce a straight 31 days?


Of course:

$cutoff = strtotime('+31 days');
$now = time();
$day = $now + 24*60*60;
while ($day <= $cutoff) {
$date = date('Y-m-d', $day);
$insert = "INSERT INTO the_table SET date='$date'";
mysql_query($insert);
$day = $day + 24*60*60;
}

Read up on strtotime(), it's really powerful:

http://www.php.net/strtotime

Cheers,
NC

Sep 24 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: willitfw | last post by:
Greetings, I am looking for some guidance on a script. My goals are: 1) have this script run automatically through a time set schedule. 2) verify if a file is updated on an ftp site (usually on...
1
by: js | last post by:
I am trying to create a primary key constraint on a view in the following statement. However, I got an error ORA-00907: missing right parenthesis. If the CONSTRAINT clause is removed, then the...
8
by: rong.guo | last post by:
Greetings! I am now doing one type of analysis every month, and wanted to creat table names in a more efficient way. Here is what happens now, everytime I do the analysis, I will create a...
6
by: skgolden | last post by:
My husband and I own a small temporary labor company and deal with 4 major clients (A,B,C & D), each of which has about 2 dozen units in our tristate area that we deal with (ie, Company A, units...
3
by: cameron | last post by:
Hi I am new here in this forum: I am writing a C++ program to calculate a Montly Mortgage Payment where the loan amount is 200,000.00 with a 5.75% interest rate with a term of 30 years. My program...
1
by: Paul H | last post by:
Can anyone give me some pointers as to how to construct a form or forms that will allow me to see a schedule of meeting rooms Booked or Available as a nice visual display. The Query that holds the...
7
by: Lucas_london via AccessMonster.com | last post by:
Hi I have set up a database/tables in Access based on daily timeseries data. However I would like to create two additional columns in the table as a basis to pull the data on a weekly and...
12
by: tasawer | last post by:
Hi, I am looking for guidelines to create a monthly recurring invoice using the following criteria. We manage vehicles for Rental companies and therefore we require to invoice same amount each...
4
by: wutang | last post by:
Create a program that displays the sum of the sales amounts made in each of four regions (North, South, East, West) during a three month period. The program should display the total sales made during...
1
by: Jiwei06xie | last post by:
I'm interested in tracking monthly utility bills....monthly charges, units/volumes, costs per unit and so on, by monthly date. The data source would be mainly from an Excel Spreadsheet (or sometimes...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.