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 4 1422
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/
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
Thank-you so much NC,
could this be changed to produce a straight 31 days?
Darren
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| | |