Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Date Comparison Calculation


I want build and extract data from a mysql table by date. The problem is that my table data needs to be by date range as follows.

Example: key field is DATE field
row 1: 02-19-96 to 02-06-97
row 2: 02-07-97 to 01-27-98
row 3: 01-28-98 to 02-15-99

and the input for the query will come from a FORM input (without range), example:
Enter birthday input value could be 05-13-96 How can I query the table and select the row with the correct range.




View Complete Forum Thread with Replies

Related Forum Messages:
Date Comparison - Checks If A Date Is In Between Two Other Dates
I'm having trouble writing a program that checks if a date is in between two other dates or not.

$today = date("d-m-y");
$a = "09-09-06"; //September 9th, 2006
$c = "09-09-09"; //September 9th, 2009

if($a <= $today && $today<$c){
       echo "Wee";}
else{
echo "Wrong";}

When I try outputting this, it outputs always outputs "Wrong" for some reason, although $today is clearly inbetween $a and $c (Sept.09'06 and Sept.09'09). Am I doing something wrong?

View Replies !
Date Calculation Now And A Date In A Table
is it possible to calculate the difference between todays date and one stored in a database. So if todays date is 2 weeks after the date in the database table do something like hightlight the result.

View Replies !
Date Calculation In PHP
Hi!

I'm trying to get a date with PHP i.e. 14 days from now in yyyy-mm-dd or any other format like print (date("Y-m-d")) + 14 days.

Is there an easy way to do this??

View Replies !
Date Calculation
I would like to make a selection from the database in the following manner ie which is created in the last 1 week or last 2 weeks. There is one field named created_date in the database and the date is in the format yyyy-mm-dd. I have seen date calculations based on month and year but didn't see one on a week basis.

View Replies !
Date Comparison
I have a date in a mysql database that was entered as a varchar field rather then a date formatted field. So the dates in the database look like so:

03/28/06
11/28/06
4/02/06

so either MM/DD/YY or M/DD/YY

problem is now I need to do date in ranges from lets say
03/01/06 - 07/01/06

View Replies !
Date Input And Calculation
I need to input the time into a form for a start time and an end time, and write it to the database. I also need to calculate the time to see the time elasped, and input that into a database, for a field of time spent.

View Replies !
Problem With Date Calculation
im a really noob fresh starting php programmer:P

but i need really to solve this problem witha php script:

I can rent a flat from 01/01/90 to 01/01/2011
ill rent that flat for a time that i will choice from that timeline above,
so ie I could rent that flat from 01/15/93 to 01/15/95.

well at this point i need to know how mani days for each year i rent that
flat in the above case it would be like this:

year 1990= 0
year 1991=0
year 1992=0
year 1993 = 15
year 1994=365
year 1995=15
year 1996=0
year 199...
year 2011=0

since im really noob could plz give me:
1)an input about the logic process to use to write a script
2)wich command i should use
3)a whole script or an idea of it if u can

i know the days from and to each period, i cant just find the right routine
to get the above datas

View Replies !
Simple Date Calculation
I have two dates and I would like to get the difference in minutes:

$date1 = date("Y-m-d H:s:i"); // now
$date2 = // a date in the same format as above just retrieved from the database it will be in the future

So I would like to get just the minutes between them.

View Replies !
Time / Date Calculation
I'm having trouble getting this code to work. can someone please take a look and tell me what I'm doing wrong? I'm trying to calculate time in minutes/days of the 2 dates.

<?php
$dateFormat = "m/d/Y H:i:s";

$targetDate = "4/13/2007 05:14:01";
$actualDate = "4/13/2007 04:14:01";

$secondsDiff = $targetDate - $actualDate;

$remainingDay     = floor($secondsDiff/60/60/24);
$remainingHour    = floor(($secondsDiff-($remainingDay*60*60*24))/60/60);
$remainingMinutes = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))/60);
$remainingSeconds = floor(($secondsDiff-($remainingDay*60*60*24)-($remainingHour*60*60))-($remainingMinutes*60));............

View Replies !
Special Date Calculation
If you start my class on Monday,Tuesday, Wednesday or Thursday, you will Graduate on the 7th Friday. ALWAYS. You always grad on Friday. I want to make a web form that you can put a start date in, and it will return the Grad date.

Any ideas? I've thought about building a database table with the dates in it, and also just using PHP or Javascript to do the calculations.

View Replies !
Datetime/date Comparison
I have a timestamp field in a customers table, which is set to the current date/time when a new customer is registered. I want to run daily reports listing all customers who registered that day, but I can't simply query the db (MySQL) where timestamp = &#392000;-0-521'. Do I need to check for "where timestamp >= &#392000;-05-21 00:00:00' and timestamp <= &#392000;-05-21 23:59:59"? If so, how do I convert a date to a datetime type?

View Replies !
Date Comparison Check
let's say you have the following strings:

7/20/02
7/20/03

and then you have this string: 8/15/02

Now let's say you need to verify that the string 8/15/02 is a valid date occuring within the date range of the first two date strings. What are some functions and practices that could be used to accomplish this?

View Replies !
Date Differences/comparison
I have two dates.. Wednesday 12th of July 2006 03:53:57 PM and Monday 31st of July 2006 03:49:49 PM

I need to find out the days between these two dates. Now how exactly would i do that?. I tried using strtotiime.. but it gives me -1 for some reason.

View Replies !
Date Comparison With 5 Variables
I have 5 variables $date1, $date2, $date3, $date4 and $date5. I need a way to analyze the 5 dates and find the one that is next from the today's date. I'm sure it's fairly basic, I just don't have the slighest idea of where to begin.

View Replies !
Date Calculation Problem W/ Mktime()
I am having a problem with calculating a date. What I am looking to do
is get the date of Sunday of this week, then use mktime() to find out
other days in the past by subtracting days.

In the code below, today is Saturday, October 16, 2004, this week's
Sunday is 2004-10-17. I successfully get that.

But, when I try to subtract 7 days using mktime(), I instead of getting
2004-10-10, I get 1969-12-31.

I have looked through php.net/mktime and searched some example via
Google, but I stuck. Any help would be greatly appreciated.

CODE BELOW:

$today = unixtojd();

// GET THIS WEEK'S SUNDAY
$this_sunday = $today + (7 - jddayofweek($today)) % 7;
$current_sunday = jdtogregorian($this_sunday);
$this_sundays_parts = explode("/",$current_sunday);
$cur_sunday = $this_sundays_parts[2] . "-" . $this_sundays_parts[0] .
"-" . $this_sundays_parts[1];

// GET LAST WEEK'S SUNDAY

$last_sunday = date("Y-m-d", mktime(0, 0, 0,
date($this_sundays_parts[2]), date($this_sundays_parts[0]),
date($this_sundays_parts[1])-7));

// PRINT OUT THE DATES
print "This Sunday is " . $cur_sunday . "<BR>";
print "Last Sunday was " . $last_sunday . "<BR>";

View Replies !
Date/Time Worked Calculation
I`m trying to write a function to calculate the hours worked by day or night and how much a person get paid according to the following criterea:

daypay is when worked between 8Am and 8PM and nightpay is when worked between 8PM and 8AM.

Sometimes the person starts just before 8PM and continue work untill after 8PM , or starts his duty after 8pm and ends before or after 8am next day.

Here is what I tried to do so far , yet its not working for all cases endtered. Code:

View Replies !
Date Difference Calculation Problem
currently my code is:

$resultup = mysql_fetch_array($result);
$amountaccessed=$resultup['accessed'];
$datepurchased=$resultup['datepurchased'];

if($amountaccessed>1){

how can i change this that the if is
if amountaccessed>1 and $datepurchased>100 hours from todays date then

can someone help me with this?

View Replies !
Date Comparison For X Amount Of Time
Is there a way with the Now date to do something like:

From the timestamp of "when this event happens"...
dont allow this until X amount of minutes have passed from "when that event happened earlier" if you get me.

So basically the users go to a "jail" and in jail they cant leave till their time is up... but im not good at cron's so trying to find a different method of working out when a time has passed...

View Replies !
Date Arithmetic/comparison Anomaly
Consider the following output which is curiously WRONG, considering THAT the code which generated it (below) expressly states "IF TODAY IS LESS THAN..." while the output clearly indicates that TODAY IS EQUAL TO

2006-12-06 -this is TODAY
2006-12-06 -this is the current marketing period (should be 2007-01-03)
2006-12-10 - this is group_2's current marketing period (should be 2007-01-03 +4 days')
2006-12-06 --this is marketyingCycle[11]
2007-01-03 -this is marketyingCycle[12]

<?php
//GMT -7 hours
$today = date('Y-m-d');
$year = date('Y');
$marketingCycle = array();
$start = strtotime("first wednesday jan $year");
$te = (28 * (3600*24));
...........................

View Replies !
MySQL Query Using Date Comparison
i have a query to the DB that shows me the number of inquiries per property in the last year (see query below). Code:

View Replies !
Problems With Strtotime()/date Comparison
I've a field in my database called CheckDate (type: date) in the format yyyy-mm-dd. I've 2 user inputs $start and $end in the format yyyy-mm-dd. I would like to check if the CheckDate is between the dates, $start and $end. Code:

View Replies !
Quarters Of Each Year Calculation From Specific Date
For an application, I need to identify quarters of each year. So once the concerned manager logs in to the system, code should check the candidate joining date and compare with the current month. If its complete each quarter, an email response should go to manager and inform to fill the form.

View Replies !
Convert Numerics To Date For Comparison Purposes
OK so I MUST be being completely stupid but here's my problem. I have two separate variables that include numeric string referring to a date in UK format (ddmmyyyy) as follows:

$traveldate = 05042007
$orderdate = 03032007

I need to perform an action if $orderdate is more than 3 days from $traveldate, i.e. this is an 'earlybird' reward. How the heck do I convert the string to a date and then compare the two to determine what action to take?

View Replies !
Timestamp Comparison With Java.util.Date.getTime() Timestamp
I am forced to have to compare the value of some PHP timestamp with a
Java-based java.util.Date.getTime() timestamp. Let me show you how
they look:

View Replies !
AVG Calculation
how to times my AVG answer by 10, my AVG shows and answer of 5 and i want it to show 50 representing the percentage, Also how would i show this as a percentage not a normal number.

View Replies !
Calculation
I'm creating an order form whereby result is displayed in the next page.

<input type="radio" name="gift" value="toy A"/>
<input type="radio" name="gift" value="toy B"/>
<input type="radio" name="gift" value="toy C"/>

They cost $5, $10 and $15 respectively.

<input type="checkbox" name="extras[]" value="Ribbon" />
<input type="checkbox" name="extras[]" value="Card" />
<input type="checkbox" name="extras[]" value="Wrapper" />
<input type="checkbox" name="extras[]" value="Box" />

Additional $1 for each of the extras checked.

How can I know which toy is chosen, which extras are selected and total up the cost? I just need to display the final total cost.

View Replies !
Sql Calculation
I just started using php and mysql for the past 1 month and slowly picking things up: i got a question on DB calculation. Pls refer the table below:

account number ¦ payment
-----------------------------
45621 ¦ $100.00
45621 ¦ $50.00
42000 ¦ $70.00
42000 ¦ $20.00
42000 ¦ $30.00
45656 ¦ $95.00

For the account number, notice that there is duplicate account number with different payment value. Now, how do I calculate the total value for each account ie: for 45621 = $ 150.00 and 42000 = $120.00.

View Replies !
Binary Calculation
I need some way of determining which bits are set in a binary number.

eg.

Decimal Number: 40
Binary Number: 00101000

How can I determine that the binary equivalent of 8 and 32 are set??

View Replies !
Duration Calculation
I had a look at a post here in regards to this issue but after it i was blank. I gave it a shot and i got a wrong value.

View Replies !
Time Calculation With Php
users of my web site enter time and distance of a run the did into a http-form. the data will be processed by a php-script and stored in an mysql-database. what i want to do is to calculate from the data what time they needed for a 1k-run -> i.e.: if one runs 12k in one hour it will be 5 minutes for 1k.

the problem is, the data from the textfield of the form comes in as a string and hence i just can't divide the data ride away.

time input should look like: 1:00:00
distance input should look like: 12
and output should look like: 0:05:00

any ideas?

View Replies !
PHP Math Calculation
I am trying to perform a simple calculation from variables passed from a form. The code is as follows:

<?php
echo "Bonus for the year: <b>";
$x = (($awage * $nibt) + ($awage * $ratio));
$x = number_format($x, 2);
print $x;
echo "</b><p>";
$xtmp = ($x + $qtr);
print $xtmp;?>

The calculation multiplies two different values (based on values from the previous page), and then sets it equal to $x. The first calculation prints fine, but when I try to add it to $qtr (also passed via radio button from previous page), it doesn't calculate correctly.

I found that if I hard-code the values for $x and $qtr after I print $x, then it will calculate correctly. I am thinking that I am using the variables incorrectly somewhere.

View Replies !
Leave Calculation
for example, for the first 2 years, he does not has bonus leave, on the third year onwards, he has 1 day increase. by default, he has 18 days leave, on the third year, he can carry forward the 10 days from the previous year, now, he has 28 days leave plus 1 day bonus leave = 29 days. same with the fourth year, he can carry forward 10 days, so, he has 39 days leave plus 1 day bonus leave = 40 days.

if he apply 2 days leave in the first 2 years, the balance is 16 days. on the third year, he only can carry forward 10 days only, not 16 days. if he apply 12 days leave in the first 2 years, the balance is 6 days. on the third year, he only can carry forward 6 days only, not 10 days. this is the problem that u don't know how to fix, can you teach me?

View Replies !
Time Calculation
does anyone know how to calculate time difference between 2 periods of time(say 12:00 am and 1:00am) ?? i have been trying to come up with an algorithm but bugs keep crawling in.


View Replies !
Days Calculation
i can't seem to get this what im trying to do is work out the elapsed time in DAYS from 2 dates code is:

             $time_now = time();
             $d2 = date('Y-m-d H:i:s', $time_now);
             $d1 = date('Y-m-d H:i:s', strtotime($ng_date));
             $days = ceil(($d1 - $d2) / (60 * 60 * 24));
when echoing out it produces:

2007-06-02 16:53:24
2007-08-27 18:00:51
which is right, but $days echoes out as 0.

View Replies !
Add Trailing Zero To Calculation
I am pulling a couple of numbers from a database (productcost and productprice).  I am trying to subtract the cost from the price to calculate the profit of the item.  I have this part working with no problem. My problem lies when the final number has a trailing zero it will drop that number (i.e. 1.2 as opposed to 1.20)

Here is what I am using:

$profit = $row_viewcoils['ProductPrice'] - $row_viewcoils['ProductCost'];
      echo $profit;

View Replies !
Calculation Form
I need to build a calculation form.. basically they click a couple radio buttons from features they want and then the user enter's in the number of words of the document and then they hit "calculate" button and it gives them an estimate for a quote. Need a little help with the structure of the form, anyone shed some light?

View Replies !
Percentage Calculation In Php
i have the following calculation code that adds the $total and the $tax variables..

number_format($total+$tax,2,'.','')

how i can calculate the total and then subtract 15% of the final value.

View Replies !
Calculation In A Query?
Is it possible to do something like this:

UPDATE `Members` SET `hungerlevel` = (hungerlevel - 1)

Im trying to run a query that updates all users in my member table and it takes 1 off their hungerlevel. I could do a while loop i suppose... i was just wondering if there was a way to do it this way.

View Replies !
Database Calculation
for example i rent a space for stock keeping and i can get 1% of total prices per day. I had created a database to record all in/out stock per day as:

[date] [status] [quantities] [unit_price]
2007-09-16 'IN' 1000 3.50
2007-09-16 'OUT' 100 3.51
2007-09-17 'IN' 500 3.40
2007-09-18 'IN' 1000 3.35

Sorry for my dumb, i'm stuck on a database calculation above. i hope any expert can show me how to get income calculation between $date1 and $date2 through sql query?

View Replies !
PHP/HTML Calculation
I am making a little Purchase order entry form for a mysql database. I have the form and can submit everything just fine, Only thing is I can't seem to figure out how to make a calculation on various text boxes.

I need to make a sum of a group of boxes, calculate taxes etc... Anyone able to point me to some sample code of a way to make arthimatic functions on the contnts of box1 and box 2 and put them in box 3. I will only be inserting box 3 into the database and that part works already.

View Replies !
ORDERING BY My Calculation
Is there any way I can ORDER BY $sum so that the smallest one is shown first, the problem is because the sum comes after the SELECT statement. This is a simplified version to my much larger problem. PHP Code:

$maths = "SELECT * FROM maths";
$mathsResults = mysql_query($maths);
while ($mathsRow = mysql_fetch_array ($mathsResults)){
$int1 = $mathsRow["int1"];
$int2 = $mathsRow["int2"];
$sum=$int1+$int2;
echo $sum;
}

View Replies !
Shipping Calculation
I've got to add another condition to my shipping calculation - right now it reads:

if ($total > 81.75)
{printf ("%01.2f", $total * .11);}
else {echo "8.99 ";}

The condition I need to add needs to accomodate International shipping - $total * .25. I have a field for '$shipcountry' - the new condition needs to identify whether the order is being shipping with USA or goes to another country... : something like....

IF $shipcountry = "USA",
THEN DO USE CODE ABOVE
ELSE $total * .25

It looks like a couple of IFs AND then ELSE to me...just wish I knew how to write it.

View Replies !
Array For A Calculation
I am currently using a an array to perform a calculation similar to

http://www.webmasterworld.com/forum88/7085.htm.

[example]
$nearest_distance = array();
$findLocations = mysql_query("SELECT latitude, longitude FROM locations");
while ($loop_findLocations = mysql_fetch_array($findLocations)) {
$latitude = $loop_findLocations["latitude"];
$longitude = $loop_findLocations["longitude"];
$yarddistance = distance($latitude, $longitude, $cutomerlat, $cutomerlong, "m");
$nearest_distance[] = $yarddistance;
}
sort($nearest_distance);
print_r($nearest_distance); // print array
echo '<br> Best Yard:'. $nearest_distance[0];

View Replies !
Calculation With Month...
I create some search option with drop down list box. search by month is 1 of them. I've a table named orders, suppose LabOrder_No & Log_date. dates are storing in database as yy-mm-dd but im retriving as dd-mm-yy.

I will select a month name from list (jan,feb....dec & their values are 01,02...12), click submit button & display the total orders & quantity of that month. to collect total quantity, i wrote a function: Code:

View Replies !
Calculation Of Items
I was just wondering what method is best to use to calculate items from a drop down menu. I have two lots of drop down menu of which i want to send to a page to clarification before being submitted.

View Replies !
Days Ago Calculation?
<?php
$month = 10;
$day = 17;
$year = 2006;

$days = (mktime(0, 0, 0, date("m"), date("d"), date("Y")) - mktime(0, 0, 0, $month, $day, $year)) / 86400;
echo $days;
?>

-> Take the seconds from unixtime now, minus unixtime date, split by seconds in a day = amount of days ago Problem is, the output is: Code:

View Replies !
Calculation Problem
im working out a users age, by deducting the year they were born from this year 2007

so i'm born on 1979, todays year is 2007

2007 - 1979 leaves 28

but the code shows as -28 instead of just 28, i tried a str_replace but no joy

  ## Year calculation
  $profileyear = $yearborn - $thisyear;
 
  ## Get rid of the - sign
  str_replace("-"," ", $profileyear);

can anyone tell me what i did wrong?

View Replies !
Comparison
I use this code to pull out messages less than 7 days old on my message board:PHP Code:

View Replies !
Comparison ASP.NET And PHP
i m working on PHP my boss decide to move all project to ASP.NET ,because it is more secure , how can i prove that PHP more secure than ASP.NET.

View Replies !
Leap Year Calculation
how can i incorporate leap year also at my below codes PHP Code:

View Replies !
Create A Function To Do The Calculation
writing the following lines of code into a simple
function. I'd like to be able to create a function to do the
calculation, then feed the $a, $b, or $c variable into it.

<?php $a = $kerryvotes/$votes;
$kpercentage = $a * 100;
$kpercent = round($kpercentage, 0);
?>

<?php $b = $bushvotes/$votes;
$bpercentage = $b * 100;
$bpercent = round($bpercentage, 0);
?>
<?php $c = $nadervotes/$votes;
$npercentage = $c * 100;
$npercent = round($npercentage, 0);
?>

View Replies !
Avg Time On-site Calculation
I am collecting the date and time of each visit to pages on a web-site into a MySQL DB. Would now like to use that info to calculate the avg time a visitor has been on the site.
What is the best way to do that?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved