473,569 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get the days between two given dates (no sql stuff)

I have two variables which look like:
$begin = "23-08-05"
$end = "26-08-05"

Now i want also to know the dates between them.
24-08-05
25-08-05

How can i do this? Any help would be appreciated.

Aug 23 '05 #1
2 1839
JAPIO wrote:
I have two variables which look like:
$begin = "23-08-05"
$end = "26-08-05"

Now i want also to know the dates between them.
24-08-05
25-08-05

How can i do this? Any help would be appreciated.


(hope this is not some course homework...)

list ($day, $month, $year) = split('-', $date);
$t = mktime(0,0,0,$d ay,$month,$year +2000)

So now you have start/end. Then:

while ($start < $end) {
do_whatever();
$start += 86400;
}

And you can use date() to convert the timestamp back to
human-readable format.

/Marcin
Aug 23 '05 #2
*** JAPIO wrote/escribió (23 Aug 2005 03:08:45 -0700):
I have two variables which look like:
$begin = "23-08-05"
$end = "26-08-05"

Now i want also to know the dates between them.
24-08-05
25-08-05


Days or dates?

For days (not tested):

<?

$begin = "23-08-05";
$end = "26-08-05";

echo ceil( (strtotime($end )-strtotime($begi n)) / 86400 );

?>

I not sure though whether strtotime() works with European format.

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Aug 24 '05 #3

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

Similar topics

6
27952
by: carl.barrett | last post by:
Hi, I have a continuous form based on a query ( I will also be creating a report based on the same query). There are 2 fields: Date Obtained and Date Of Expiry I want a further 3 columns to the right of these 2 fields to show the
2
3107
by: tasmontique | last post by:
I am working on an access 2002 flight schedule database. I am new to access but have some basic understanding of sql and vb6 code. I have learned a lot from this website. Thanks much Hopefully you can help me with this one. This database handles a varying number of flights for a varying number of days for a varying number of months. ...
5
31986
by: gsreenathreddy | last post by:
Hi! There are two given dates and I have to find out the working days between two dates i.e. excluding Sundays. Please help. Thank you.
2
1480
by: pointers | last post by:
Hi, Can we get a SQL query, to display all the dates between two given dates eg. if date1=21-mar-2007 and date2=25-mar-2007 then the query should display all the dates between those two given dates i.e 22-mar-2007, 22-mar-2007, 23-mar-2007and 24-mar-2007. Query should not contain any plsql coding. Regards.
3
4298
by: John | last post by:
Hi How can I calculate days from the two dates entered in date time picker fields on winform by a user? Thanks Regards
9
11581
by: sha2484 | last post by:
I need help to count days between 2 dates,where i want to count the days between current date and registeration date.Here is the code that i have write but it only compare the days , it do not compare the month and the year, where it will return 0 if the day of the second date is the same as the first date even the month or year are different,...
3
2346
by: pchaitanya | last post by:
I have selected some list of valid dates to a label. now i need to find first day among the given dates from label contrl i got dates from calender control by clicking for entire week.. that is i have dates from sunday to saturday and I have to find which date is sunday......
1
7200
by: bharathreddy | last post by:
This article will explain how we can get the count of weekdays in between two dates. This will be usefull if we want to count the number of working days between two dates. Example: ------------- USE GO --This function is used to count the number of weekdays between -- two dates. create function udf_Weekdays(@Weekday,@BeginDate...
2
1565
Jerry Maiapu
by: Jerry Maiapu | last post by:
I am trying to punch into a table a bunch of dates that fall between two given dates. When compiled,no error but when on run does not do anything..(i.e nothing in the table) Can someone figure out what's missing? Option Compare Database Option Explicit Private Sub cmdinsert_Click()
0
7921
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7666
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.