Calculate Days Worked
I have a set date in my MySQL database that records when a Sales Lead
is established and I echo that date as $row_rsLead['lead_date'];
I need to be able to calculate how many days that lead has existed.
$row_rsLead['lead_date']; outputs as 2007-06-14.
I have made numerous attempts to create a function that will calculate
the days between the lead_date and today's date, but have made
absolutely no headway. I am either stuck working between differing
date formats or really strange numerical outputs.
If there is a script someone is willing to share or point me in a
direction that is good for a relative newcomer to PHP,
View Complete Forum Thread with Replies
Related Forum Messages:
Dates, Daylight Savings And Net Days Worked
I'm trying to mimic the functionality of netdaysworked in excel. The code below works, except when the date starts during daylight savings time. what is the number of seconds in a day for a daylight savings day? for ($dayval = $startdate; $dayval <=$enddate; $dayval+=$oneday){ if (date(I,$dayval)==0){ echo("daylight savings time<br>"); } if(date(w,$dayval)==0){ $daysworked = $daysworked+0; } elseif(date(w,$dayval)==6){ $daysworked = $daysworked+0; } else{ $daysworked++; } echo("first day: ".$dayval." number of days ".($dayval/86400)." lastday : ".$lastday."day of week :".date(w,$dayval)."date: ".date("m- d-Y",$dayval)." days worked: ".$daysworked."<br><br>"); }
View Replies !
Calculate The Number Of Days
I am trying to calculate the number of days a house has been on the market. I am using this: CURDATE( ) - listDate I thought this was working fine until I added records with a list date starting the month prior. for some reason 13 day olds were showing as 83, 14 days were showing 84, and so on. All adding 70 days.
View Replies !
Calculate Number Of Days Between Two Dates
I have people posting ads and when the ad is posted I have two fields populated at that time: date_created date_expired With the date expired being 7 days after the date created. Both are in this format: 03/12/07 What I am doing is preventing someone from posting more than one ad per 7 days. I'm validating against their email address for that. But I want to display the date that they would be eligible as well as determine if they are eligible to post or not which would require comparing today's date with probably using the now() function against the date_expired in the database. If the today's date is past then no problem. If not, then it would display an error. Code:
View Replies !
Calculate The Number Of Days Between A Given Date And The End Of The Month.
I was hoping someone can help me with a date calculation. I'm trying to calculate the number of days between a given date and the end of the month. I have a form with three drop down boxes: month, day and year. A user will submit a date using these drop down boxes. Based on their submission, I need to determine the number of days to the end of the month from the date which was submitted. For example, if the person submits March 15, 2007 and the last day of the month of March is March 31, 2007. The number of days between the 15th and the last day of the month is 17. How do I begin programming this calculation? Since the last day of the month differs from month to month (28th, 30th or 31st) I cannot figure out how to determine the last day of a given month.
View Replies !
Calculate How Many Days User Has Stayed With The Book Once She Return It).
I am learning PHP/MySQL, and I am also writting the Library Management System to make sure that I practice what I am leaning. My Problem is: I want to capture the date when the library user borrow the book and then check that date to see if the book have exceeded the number of days (to calculate how many days user has stayed with the book once she return it). Please help me how I can do that. I am using mysql as my database.
View Replies !
Have You Worked With Punbb?
I'm looking into BBs that I can modify to suit my needs. I came across PunBB which I'd never heard of before. Have you worked with this Board and can you shed some light on it's performance, flexibility, security, and ease of use?
View Replies !
PHP CLI - Can It Worked As Shared Application ?
I have an a couple of utilities I would like to create for a customers that convert data from a CSV file to an ODBC datasource. I have a protoype working on my laptop, but when I install these at the client's site, I was wondering if I could install PHP on their server and have selected workstations "share" access to the PHP interpreter or does each workstation need there own copy/installation of PHP ? BTW, I will be using the Windows version in all cases. In other words from the workstation, I would like to execute a script with a command like "J:phpcliphp.exe myscript.php"
View Replies !
Has Anyone Worked With Sessions & Classes?
do you have any code examples of how you made sessions work within classes? I've been having a lot of trouble with this and am hoping someone will have a solution (if it's possible). What I'm trying to do is create a class that pretty much is the heart of my application and I'd like to do all the session work in this. So far in my research and testing development, I've come up with the following: PHP Code:
View Replies !
RewriteRule Worked Once, Alas No More
mod_rewrite is not easy, but I'm having a doozy of a time getting the simplest rule to work: RewriteEngine on RewriteRule ^/dis.php /dls.php ErrorDocument 404 /404error.php This is to correct a common spelling error. I keep getting the 404 document. The rewrite worked ONCE sometime in its 2 hour creation process, but then stopped working so I've pared it down to the bare essential. I've been starting at a screen for aforementioned 2 hours and my eyes are about to fall out. Code:
View Replies !
Time Worked On Easy But Not Now
When i started to build my site I used easyPHP. For those of you who dont know what easyPHP is, its basically Apache, mySQL and PHP all in one. I've now bought the domain, webspace etc and somethings now not working correctly The trouble i am getting is that if i had a simple query such as: $result = mysql_query("SELECT DATE_FORMAT(timeadded, '%H:%i) AS time1 FROM bands", $connection); $row = mysql_fetch_array($result); $timeadded = $row['time1']; echo $timeadded; If would work on easyPHP but it doesnt work now :-S $timeadded is empty. I've checked the database and theres definitely a value in there. This problem is only occuring on the time. Its fine with dates etc.
View Replies !
Data Transfer Worked In 4.4.4
I am passing data from an embedded device using Content-Type = multipart/form-data. My data passed nicely into $ variables when the server ran with PHP 4.4.4 but now that it is upgraded to 5.2.3 none of the data is passing.
View Replies !
Getimagesize-worked On Osx But Not Linux For Flash
is there any way to get get the dimensions of a flash video including flash 6, the thing is getimagesize worked for flash 6 files on my osx computer but my linux wont do it even though they are running the same apache and there is only an extremely small difference in versions difference in php versions(4.3.2 compared to 4.3.3) so if there is another way to get the dimensions with php could someone tell me, i can't find a way to do it and i know this has been asked a million times but i can't find the answer i have a site i'm hosting and have decided move it to linux, but when i did that 1/2 of the flash files just stopped working with getimagesize, so it this a bug in php 4.3.3 that wasn't in 4.3.2 my os x server says Apache/2.0.47 (Unix) mod_ssl/2.0.47 OpenSSL/0.9.6e DAV/2 PHP/4.3.2 and my linux says Apache/2.0.47 (Unix) PHP/4.3.3 is it one of those modules in my osx computer that made getimagesize work.
View Replies !
Sessions Not Saving, Worked On Windows, Not On AIX
Developed on Windows (apache/mysql, no register globals or other nonsense) Moved everything to AIX and have the following problem: Nothing is saved in my session folder. Yes, I've created the directory. Yes, the apache/mysql/php user has write access to that directory.
View Replies !
Variation Of This Script Worked For MySQL
I edited this script changing the parts which should hypothetically make it work with MS SQL... But it doesn't work. Is there something glaringly wrong or missing? It worked like a charm when I had everything coded for MySQL.. Code:
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 !
Ordering A Table From A Ratio Worked Out By Data In SQL
I have a SQL database that stores wins and losses, what I wish to do is order it in a table, so the people with the BEST ratio are at the top. I don't know how to do this, at the moment it's just ordered by the most wins, then the ratio on the end of the table worked out using some basic PHP. Here is my code:
View Replies !
PhpDocumentor: No "page-level Docblock" But Worked Without...
I am using phpDocumentor to generate documentation for my files. This worked without problems but today it told me "has no page-level DocBlock, use @package in the first DocBlock to create one" for ALL of my files, but I definetely have those @package lines. Did anyone observe this strange behaviour? Any tips for me? Perhaps new versions of PEAR/PHP/Zend Optimizer I installed recently damaged the installation. I reinstalled phpDocumentor several times (manually AND using PEAR)
View Replies !
Calculate A Value That Is In The Db
i want it to calculate a value that is in the db if the db has the value 6 pound(s) (i have a submit button) and the users enters in the input box a value for more pounds then how do i make it calculate in fractions or even divisions.. cause see this is what i have. PHP Code:
View Replies !
Age Calculate
I need to run a query if a user age is within specified age range. User age is store in a table in 0000-00-00 format the age limits are passed by two vars: PHP Code: $ageMin = 25; $ageMax = 35; I can do it in a php function but I'd like to perform this validation in a query string. Is it possible?
View Replies !
Calculate Date
I have a date 11-07-2007 22:06 and i want to know how to calculate 4 hours ahead and create a count down system $date_now $date_4hours $countdown = $date_now - $date_4hours;
View Replies !
Calculate Rank
I need to display the rank of my players. The rank is based on this row: c_strength What would I use to count their rank, ie: Rank: 54 of 5,231
View Replies !
Calculate The Percentage Of 250 Between 150 And 450
Say I have two numbers, for example 150 and 450....and a third number between them, say 250. I want to calculate the percentage of 250 between 150 and 450, where 150 is the 0%, and 450 is the 100%. I know there is a certain formula, but seeing math was never my favorite course, I can't just figure it out.
View Replies !
Calculate Months
I would like to make the login form so that you can only have so many failed login attempts. For example, I would like to make it so that if you fail to login correctly after 5 attempts, you won't be able to for 10 minutes.
View Replies !
Best Way To Calculate A Rating?
ive got some code which ive written which takes 5 values from a database and calculates the average then displays the average as a certain number of stars. the code works perfectly so there is nothing wrong.. its just a bit long and i was wondering if theres a qicker easy way to do the same thing? or if i should just stick to what ive got. Code:
View Replies !
Calculate Many Downloads
I want to know how many successful downloads from website, is there some PHP script can do this? Let's say I have file "abc.zip" people can download, The system is Apache+linux+php+mysql, how I can know exact how many successfully downloads and the download time. I know it can be done by weblog statistic, but I want to know is there some way in php can do it so I can save in database and view real time result.
View Replies !
Calculate Cost
I have an equipment table. In this table there is an onhand, receivedqty, and totalcost fields. How can I query to get an average cost and extended cost. The math would be totalcost/receivedqty=averagecost and the extended cost would averagecost*onhand. Is it possible to do the equations within the mysql statement. I tried the below but it won't let me use average to get the extended cost.
View Replies !
Calculate Volume Discount
I'm trying to create a calculation that will look at the qty ordered and compare that to the quantity discounts. An example is as follows. Product = Bronco wild horses 1,000(horses) = $300.00/m 2,000 = $150.00/m 3,000+ = $100.00/m etc. /m=per thousand So if I order 2500 horses the php page will look at the value entered, select the proper price and calculate the final total. 2500/1000=2.5X$150.00=$375.00 for 2500 Bronco's. As you can see below, I've got the formating for the final total, But I don't know how to have it find the right price. Code:
View Replies !
How To Calculate The Day Of The Week By A Given Date.
I'm currently working on a (simple) calendar system which allows registered users to add an event to the calendar. The table EVENT stores info about the author, date and description of the event. I then managed to output a list in which only events of this year are showed and are grouped together by months. And now I only need one more thing to complete the script. I want to output for every event on which day of the week it occurs (monday - sunday). I've looked around for tutorials but haven't found a basic one.
View Replies !
Calculate Crc32 Of File In Php
I am having a problem calculating a crc32 hash of a file in php. I have uploaded a file, calculated an md5 hash and it is correct, both using md5_file() and hash_file("md5",filename) and they are both correct (tested with md5 command on osx and MD5 in Java). I am using hash_file("crc32",filename) and this gives a different result to crc32 in Java and crc32 command on osx.
View Replies !
Calculate A Firefighters Schedule In PHP
I need to calculate the following schedule in php. What I need out of the script is what shift is working “today” E.G. $shift = d;. There are 4 shifts working 24hr days starting at 7 am. The days rotate on 28 day cycles. E.G. ‘C shift’ is working on July 1 (Sunday) the next Sunday they work is the 29th. I found some code that works with 3 shifts on a different cycle but I have 4 shifts. Code:
View Replies !
Calculate Totals In A Loop
I am trying to calculate the totals of all the fields pulled up in a loop... i.e. I have a database called "checkout" that has bidder numbers, lot numbers, and amount for each lot number. When a person wins an auction (this is a live auction not an online auction) we enter a new row in the database that has the bidder number, the lot number, and the amount. After the auction is complete and they are checking out we have the script pull all the rows where the bidder number equals the bidder who is paying, it displays their bidder number, and lists each lot number and amount for that lot on separate lines in a loop statement. I would like to have a final line at the end of the page that displays the total of all the amounts listed. I.e. if they have lot number 12 at $50 and lot number 10 @ $27 and lot number 55 @ $63 the script displays as follows... bidder number: 101 lot number 12: $50 lot number 10: $27 lot number 55: $63 And I would like the end to say total: $140 How can I do this? I appreciate any help... Here is a copy of what I am working with now. Code:
View Replies !
Calculate Percentage Discount
I have a field which holds a numerical value lets say 29.99 Based on whatever the value of this number is I then want to calculate 5% of the value Do I just do $discountPrice = $totalPrice * 5% Im not sure what syntax to use to achieve this
View Replies !
Calculate Dates Given Beg And End Date
I am trying to figure out how to generate a listing of dates using the following known values: begDate = 2007-07-03 endDate = 2007-08-30 recurDates = Tue|Thu Question is how do I generate the YYYY-MM-DD for each of the dates between begDate and endDate for each of the recurDates?
View Replies !
Calculate Difference Between Dates
I've to build a function that tells me the resultant date from adding a number of days to a date. Example: function adddate(date, days) { return date + days; } For example if I call with this...adddate(2007-05-05, 5) it should give back a 2007-05-10. I've tried but is hard! It should work with any number of days.
View Replies !
How To Enumerate And Calculate Timezones?
In a web database (PHP), per user, I'd like to allow each user to specify their timezone (this would change how times are adjusted for display for that user). How do I enumerate all possible timezones from a PHP script or compiled 'C' program? Given a specific timezone, how do I get the time adjustment from UTC (which can vary, based on daylight savings rules)? Code:
View Replies !
Calculate And Show % Saved
I would like to thank you guys in advance for your time and help offered. I am trying to setup a page that will multiply any number entered by user with a specific cost and display the sum as well as percentage saved, all on the same page (or even in another frame). Secondly I need this keyed number to be used as the default for the payment page that follows. Basically i want to show my customers what they save before they get to payment page.
View Replies !
Calculate Color Proximity
I want to compare 1 color (hex or rgb) with a list of colors and choose the more similar of the list. For example I have #FF1202 and an array with: array ("FF0000", "00FF00", "0000FF" ...); I need to find the color more similar in the list (in this case the first: FF0000).
View Replies !
Calculate Bandwidth Usage
When a user registers to my site, I give him a folder to create his web presence (free hosting). Is there a way to calculate the traffic usage of his folder contents? They could be anything from text files to movies and flash.
View Replies !
One Query To Calculate Stock
I want to calculate my stock. the formula is : end of stock = beginning of stock + purchase - sales (I make it simple ... so I didn't include 'stock return' and 'stock opname' etc) My stock table is : prodid (varchar) bos (double) -> beginning of stock Purchase table is : date (date) invoiceID (varchar) prodid (varchar) qttybuy (double) Sales table is : date (date) invoiceID (varchar) prodid (varchar) qttysales (double) How to calculate my 'end of stock' using just one query.
View Replies !
|