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

writing a screen scraper
Hello,

I'm writing a screen scraper application and want to be able to get absolute addresses

Polymorphism
Was wondering if someone could explain this a little better to me. I had always assumed that it had

Pro-rata Billing in Periodic Billing for Rental
Hi guys,

We have a situation, where a rental contract starts at the mid of the month say

Problem with the Update command used with a sqldataadapter
I'm connected to a database on an SQL Server and I'm using a sqldataadapter, sqlconnection, sqldatas

Wierd if else problem
Hi guys,

this probably aint wierd for you, but it seems like php is playin up to me. may b i

Prevent PHP mail( ) from appending hostname to from address
Hey guys,

I want to be able to send texts to phones via email (since each phone has their own

Change Web page language
i doing this thing first time but i dont find any suitable solution for it. On the demand of user. I

A little help needed passing hidden values to next page
I have a page that has hidden values in a form.

example
Code: <input name='signupID

extending tidy
I have problem with type-hinting and extending tidy. This code creates error:
Code: class cMyTidy

Solution Manager BPR
Does the SolMan-BPR-ARIS-Integration (http://www.ids-scheer.com/en/ARIS/ARIS_Platform/ARIS_Business_

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