INSERT for date range


Posted on 16th Feb 2014 07:03 pm by admin

Hi all

I have the following table

Code: [Select] `date` date
`day` int(2)
`month` int(2)
`year` int(4)
If I pass a date range in PHP, such as

Code: [Select]$datefrom = '2009-02-20';

$dateto = '2009-02-25';
How can I get it to INSERT a record for every date between that date range?

So with that example date range, it would do

Code: [Select]INSERT INTO `dates` (`date`, `day`, `month`, `year`) VALUES
('2009-02-20', '20', '02', '2009'),
('2009-02-21', '21', '02', '2009'),
('2009-02-22', '22', '02', '2009'),
('2009-02-23', '23', '02', '2009'),
('2009-02-24', '24', '02', '2009'),
('2009-02-25', '25', '02', '2009')
but not do an INSERT if any of those dates already exists in the database.

Any help would be great

Thanks

No comments posted yet

Your Answer:

Login to answer
256 Like 53 Dislike
Previous forums Next forums
Other forums

socket makes browser hang...
I have a socket server, and I am having a problem at the moment...

A browser sends a http hea

How to change Time Zone
HI
I want to change the time zone of the server to another country.How can do that?

Thanks

pointer 102 question
I read a book
1
2
3
4
5
6
7
8
9
10
11
12
int main() {

ClientScript.RegisterClientScriptBlock Issue
This is what I haveview plaincopy to clipboardprint?Protected Sub posrback_Click(ByVal sender As Obj

Undefined offset
The following script checks to see if the user answer matches the correct answer.

Form Fiel

Oracle Connectivity
Hi Every One,

Can we access SAP from oracle database.If it possible then please spec

Warning: Cannot modify header information - headers already sent by (output sta
Warning: Cannot modify header information - headers already sent by (output started at /home/praylif

parsing error
can anyone explain this syntax error:

Parse error: syntax error, unexpected T_IF

The e

Filtering an Array Based on Value
I have a very simple script set up that pulls data from a database and is output using this code:

output_buffering so rewrite
I'm planning to rewrite some of my scripts so they don't have to use output buffering to accomplish

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash