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




Date Database?


The admin assistants can enter the number of hours that each employee has worked on a particular date in a particular month (hours are variable depending upon customer demand) and at the end of the month need to run off a pay slip for each employee containing the following data:

I know how to add, delete and modify the data, the only thing im not sure of is the databse structure for the dates.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Date Is Not Being Pulled From MYSQL Database, Instead Current Date Is Displayed!
I am having trouble pulling a date from a database using PHP at the <a
href="http://www.mytuneslive.com/ameshkin69/"> following page.</a>

Here is the code. As you can see, it is just making the date the
current time. The values in the database are UNIX timestamp, and the
DATE() function is used to convert from UNIX to readable date. Can

<td width="55%" align="left" valign="top"><?php
$row_comment['timestamp'] = date("n d Y g:i A");.....

DATE Doesn't Get Into Database
I have a HTML-form with a 10width field in which you can enter a date. But whatever I enter. In the database I always find 0000-00-00. The variable comes through. I checked that. Does anybody know what I do wrong ?

Inserting Date Into Database
I have a pretty simple news code that inserts the data, and then is retreaved, with a pretty simple scheme. I have a date column set at timestamp(14), and I'm trying to insert NOW() as the date. I browse with phpmyadmin and all it has is 14 zero's. PHP Code:

Displaying Date From A Database
All I need to do is change the date so it reads, for example, May 1999 when it's displayed on the page. Code:

Inserting Date In Database
I have form which allows a user to select a date as part of the form.
On submitting i am getting no update to the database and no error message.
To try and test it i created a shorter version which sets up the variables except the date.This gives the same result.ie no update. Code:

Filtering Results By DATE Value In Database
I have this code in my page for displaying some data from a database, sorted by date. i had posted a messed up version of this a while ago but I couldnt get it working even after a few suggestions. PHP Code:

What Is The Proper Date Format For A Txt Database?
I would like to know what format should be used when writing to a txt file. I am trying to search between a start date and a ending date and list any variables For example.

if (($sDate <= $jdate && $eDate >= $jdate))

then I have it list the variables it will work if searching between months and days but it does not work if I have different years. I will get all years printed out.

my date format is m/d/Y 6/13/2001

If I search for example start date = 6/01/2001 and the ending date = 6/09/2001

I will get the correct month and day dates but I also get anything from the year before and including year in the future.

Date & Time Format In Database.
I'm using MySQL database, the problem is I've setup that user input the Date format in dd/mm/yyyy (example: 14may2007) and Time (example: 12:00pm). How do I convert it to Date & Time format in database format before insert into database? Sorry, noob here.

Calculating Dates From A Date In The Database?
I`m using this format of dates:

$entry_date = strftime("%B %e, %Y %H:%M:%S", time());
And that time gets saved into the database (birth in ownedpets database):

$res = mysql_query("SELECT id, owner, pet_type, pet_name, birth, food, play, datetime FROM ownedpets WHERE id=$id");
$rows = mysql_fetch_row($res);
mysql_free_result($res);

So let`s say in this case, the database birth value ($rows[4]) is October 19 2007 20:00:00. What do I do to tell php to check to see if the current date (hours and all don`t matter) is 21 days after the $rows[4]?

Why I`m looking for this task:
For the pets system, if the pet is 21 days after it`s birth, it will be an adult. But if it is not 21 days after it`s birth, it will still be a baby.

Today's Date In Database Insertion
How do I insert today's date in a certain database row without using the date() function for a string?  For example, when you use PHPMyAdmin to insert a new table row and there's a column with the type "date", it gives you options such as CURDATE, NOW, etc.  How would I use that in a database query?

Convert Date From A Database Query
I have a simple database for events. I have a column named "date" that I would like to display as "March 8, 2007" on the webpage. What do I need to add to change the date format? Here is my php code:

Reading And Displaying A Date From A MySql Database
I've just started using php, and although I am very impressed by it,
there are some things with which I am confounded!

What I'm trying to do is read in a Date from a mySql database and then
display it on screen (the Date is in the usual yyyy-mm-dd format).

If I use SQL on phpadmin
SELECT Date
FROM details
WHERE details.Name = "Paul Lee"
LIMIT 0 , 30

The result comes up 2005-01-01, so this seems to work.
But if I use the following:

$db = mysqli_connect("localhost","root","");
@mysqli_select_db($db, "personnel") or die ( "Unable to select
database" );
$query = 'SELECT Date FROM details WHERE details.Name = "Paul Lee"
LIMIT 0, 30'

$result=mysqli_query($db, $query);

echo "<br>";

echo $result;

mysqli_close($db);

I get "Object id #2" displayed on screen.
I have tried to use the explode function to separate the months, year
and day using the "-" as a delimeter, but this doesn't work, and I
can't seem to get the other php date/time functions to work either.

Inserting A Date Into A Microsoft Access 97 Database
I was wondering if anyone could help me insert a short date into microsoft access 97 using php? i can insert text no problem but i can't seem to be able to insert a date properly. i have been using

//$date = "#" . "$sqlmonth" . "1" . "$cboyear" . "#";

$strSQL = "INSERT INTO tblSupport (tDate) VALUES ($date)";
$result = odbc_exec($connect, $strSQL);

Note: i can insert a date if i hard code it like putting in #01

How To Find The Last Accessed Date Of A MySql Database
How to find out the last accessed date of a MySql Database. I have around 200 databases in my server some are used and some are not in Use, I want to remove the database that are not in Use. SHOW TABLE STATUAS gives me last updated Date. In my case there are some database which are not updated at all, but...

Insert Server Date / Time Into Database
I currently have the following to insert a variable into a database:

$zip = $db->escape($_POST['zip']);
$db->query("INSERT INTO zip SET zips = '$zip'");

I would like to also add the date & time the submission was made.

Pulling Data From A MySQL Database With PHP Date Code??
I am trying to find ways to retrieve data by date from a mysql database.
What I would like to do is to have the option for people to retrieve a file
that was entered in the week before the current day (something like click
here for all drinks added in the last week) I have tried to make this code
work, the only way I can is to manually change the date every day, I would
like it to do it automatically.

Taking Date Of Birth From User And Sending It To A Mysql Database
i have created a form that takes a users date of birth as 3 seperate values $day $month and $year i do not know how to combine these values into a single value called $dob.
I tries using just a singal value to take the date however it did not work, even after I had formated my database.

Convert User Entered Date And Time To Unix Timestamp Before Inserting To Database
How do you convert a user inputted date to a unix timestamp before
insterting it into your database? I have a form, with a textfield for
a date that the user inputs in the format mm-dd-yyyy and three dropdow
boxes for hours, minutes, and AM/PM. All of these need to be considered
together and converted to one Unix Timestamp and then inserted to the
MYSQL date field. The type of field is INT (11) so that I can instead
of the standard 0000-00-00 format of MYSQL so that I can do better
calculations and queries.

Sort Results By Date/time, Limit 5 Database Entries Of Today &/or Upcoming Days
I'm designing a website for my fraternity and in the database I have entries which contain past events, todays events, and upcoming events.  My problem is that I can not figure out how to sort the query results to display:
 
1) only past events based on the CURRENT DATE
2) only the events which fall on the CURRENT DATE or after, limiting the results to 5 entries
3) all events that fall on CURRENT DATE or afterwards

Example:   
Today is  September 15, 2007

Problem 1) Displaying all events that happened before September 15, 2007
Problem 2) Displaying only 5 results that fall on September 15, 2007 or after
Problem 3) Displaying all events that are happening on or after September 15, 2007

And obviously I would like the CURRENT DATE to change depending on what date it is, currently.

Ok so now I've been very redundant in my explanation of my problem here is the code and a link to what that particular page looks like. Code:

Check Date From Input Must Greater Or Equal Today Date?
I have 3 select box. Code:

<select name="day">
<option value="1">1</option>
<option value="2">2</option>
.......
<option value="31">31</option>
</select>

<select name="month">
<option value="01"> Jan </option>
<option value="02"> Feb </option>
.....
</select>

<select name="year">
<option value="2002">2002 </option>
<option value="2003">2003</option>
</select>

When I select and click submit in form. I will have 3 variable :

$day, $month and $year

How can I check the day that I choose in form must equal or greater than today date? If it less than today date. I must print error message to user.

Read Today's Date Print Tomorrow's Date
I've got a small script that writes a random number and the date to a text file. Then the script opens this text file and if date = date from this text file something must happen.
If something happened this script must open this text file again and replace it with a new random number and tomorrow's date.

<?php

$date = date("d-m-Y");
mt_srand((double)microtime()*10000000000);
$num=mt_rand(0, 20);
if ($num == $num && $date == "$tomorrowdate") { echo"$num -- $date";}
else
echo " ";?>

So if the script gets activated on the 05-05-2003 it must write tomorrow's date into the text file (06-05-2003). How will I get tomorrow's date today?

Help: Date Function Not Returning Correct Date & Time
I have just notices that the date() function is not returning the correct
date/time on my "server".

I am running apache2 on my winxp pro laptop.

My system clock is set to the correct date, time and timezone, get the
results returned by date() are 11 hours behind.

PHP Date Question: How To Determine The Date Each Of The Past 3 Sundays
How can I determine what the date was (in YYYY-MM-DD format) last
Sunday, and the Sunday before that?

For example:

Today is Thursday, August 18, 2004 (2004-08-18). I would like to have
the following variables:

$this_past_sunday = 2004-08-14
$two_sundays_ago = 2004-08-07
$three_sundays_ago = 2004-07-31

etc. etc.

Save Date To Table Field Date Type
I have a calendar picker on a form that fills a text box with  XX/XX/XXXX  date format. If I run a insert statement  the date field in the database shows 0000-00-00. If i change the field type to varchar  the correct format displays. 

What is the correct way to save a date to a mysql database?  Furthermore to query on the date  how about a select * from db_name where servicedate >= $startdate  and  servicedate >= $enddate  I supose this will not work
Any pointers?

Date Dropdown From Mysql Date Entries
For the PHP gurus out there, here is what I want to do: create a dropdown list of available dates from a mysql database date entries. But the dropdown/s should have 3 separate fields in month, day and year which in effect shows only those months, days and years that have corresponding entries from the database.

Planning to use this in the archive section of an online news publication so people can select issues to view via dropdown list that have corresponding entries only.

Start Date - End Date = Number Of Days
I have a starting date for var 1 and today’s date for var 2. I need to calculate how many days are between those two dates.

02/24/03(today) - 01/14/2002(start date) = number of days.

In theory this is easy but there are many instances were I could get an inaccurate answer. For example one consideration is that some months have 30 days others have 31. exc.

My question is, is there an easier way to solve this problem other than using endless if statments to error handle all possible instances? Does PHP4 have any built in functions that could calculate this formula correctly?

UNIX Mktime To MySQL Date Or Date
A form that sends a starting date and an ending date. I have figured out how to tell the difference between the two and even rip the difference into an array because I need to compare the individual dates against a mySQL database to pull results from a particular date in a series. This is no problem. My problem is that teh mySQL database uses DATE as a field definition and this can not be changed. I managed to pull the date differences using some cleaver mktime stuff but no I do not know how to get this 1072242000 into this 2003-12-24...

Is there a function that reverses the mktime result into a usable date format? I would take anything at this point and I can explode and then array it to get what I want - but there has to be something. Code:

Formatting Date From MYSQL Date Field
i've got a date field in my table, but the default format is YYYY-MM-DD... is there any way i can pull the date out of the database and format it differently... like DD.MM.YYYY or like April 13, 2003?

Counting Days From $date To Current Date
how to count the time between two variable dates? Such as someone inputting 6/8/1991 in a form and it comparing that to todays date... then getting the number of seconds elapsed... I know I have to use the mktime() function to get the seconds.. but not quite sure how.

The Server Date Cant Match With My Country Date.
which using Date()
the server date/time can not match with my country date/time
eg server time: 1.30pm ..but my localtime already 3.3pm

Date() Gives Me Yesterday's Date And Not Today's - Why?
$result[$i]->record_entered contains the current date as set up by
MySQL (entered as "now()").

I verified that in the database the date is "now()", which in this case
will be "2/9/2006".

However, when viewing the page using the display:

Code: ( php )

Begin Date And End Date, But No Weekends!
I am making a system to plan my work days.
If i begin on a project on 01-10-2007, and the project is 100 hour and i work 10 hours a day, it will cost 10 days for me too work.

The answer is simple, project is done @ 10-10-2007, but i dont work in the weekend.
So it must be 12-10-2007, i got the following script;, but it aint working right.

Because when the begin date and end date is more then 2 weeks, and more than 2 weekends, it doenst count the weekends good. Can someone help me, or is there somebody with a better solution? I am working two days on it, but i cant get it right



<?php

$begin_date = strtotime( date( '2007-10-01' ) );

$hours = 100;
$workdays = 10;

$total_days = $hours / $workdays; 
$total_days *= (60 * 60 * 24);

$weekend = $total_days / 7 * 2;

$enddate = $begin_date + $total_days + $weekend;

if( date('D', $enddate ) == 'Sat' ) {
echo 'End date <b>' . date('d-m-Y', $enddate + (2*86400)) . '</b> 2 days<br /><br />';
}

elseif( date('D', $enddate ) == 'Sun' ) {
echo 'End date <b>' . date('d-m-Y', $enddate + (1*86400)) . '</b> 1 day<br /><br />';
}

else
{
echo 'End date <b>' . date('d-m-Y', $enddate) . '</b><br /><br />';
}

?>

Date Conversions ( Date, Mktime )
I have a date in three pieces dd mm yyyy.
I'm just wondering the best way to convert this for inserting into a
DATETIME field and then back again when displaying it.

I have tried date, strtotime mktime but it keeps inserting a blank
date. i.e. 00:00:00 00:00...

I've been looking through the php manual but I can't seem to get this
working.
Also would I be better off using the UNIX_TIMESTAMP function?

Check Date Is Not Before Current Date
I need to validate a date entered to make sure it isnt before the current date.

I have managed to this in Javascript but not sure how to do this in PHP when the value is submitted.

Date Time Not Accurate For Date();
echo "date=".date('Y-m-d h:i:s');
date=2007-11-15 15:48:14

the clock is the accurate at here..showing only 3pm ..while now my pc showing 11.51pm(localtime)

Put Today's Date Into A MySQL "date" Formated Field
My MySQL table has a field that is set as type "date." I need to get
today's date, and insert it into that field. The default for that MySQL
field is 2006-00-00.

I know about the date() function. I have tried date("Y-m-d") and
date("U"), neither worked. The date field was just filed with all
zeros.

Can anybody point me in the right direction?

What Is Indexing In Mysql And How It Will Be Useful And How We Can Retrieve Database Content Easily From A Database Table Containing About 5lakhs Datas
I need to select data from a database table containing huge amount of
data. Now I am storing data using one primary key and I am just using
simple select statement, and this process gives me the output but it is
taking long to execute the query. As much I had heared I want to use
some indexing or cluster indexing which might help me but I am not so
familiar with these things.

Images In Database Vs. Image References In Database
i kept all of the uploaded images as files on the server, and created links to them in the database. I have been changing things around now (especially directories) and I am thinking of storing the images in the actual database. I read somewhere that this can be considered a bad practice, so i was wondering what the consensus here was. In my opinion, modifying all of the code to point to the correct directories everytime a page location changes seems like a pain in the a**.

Date And System Date
I am currently looking for a way to compare the current system time date to a date that is in my database. PHP Code:

Change $row['date'] To $date
When writing the code to display the mysql_fetch_assoc results I'd like to remove the $row[''] portion and just leave it as a variable like this: $date, $numid, $text and on and on. For the life of me I can't remember how to do it... even though I know I looked at this last week sometime.

Start Date End Date
I am creating a simple auction site. There will be a start date which I think will be a timestamp and an end date. How can I do code the end date so that it is $days until it closes? I am not asking for code (although that may be helpful) I am asking for an explanation.

Date From And Date To Fields
I have a table which contains special offers starting from a certain date and ending at another date.

Therefore would I just do

$date = date("Y-m-d H:i:s ");

SELECT * from Tablename
WHERE start_date <= '$date' &&
end_date >= '$date'

Is this correct?

How To Convert A Date To A GMT Date ?
how to convert a date to a GMT date ?

Check The Second Date Is Less Than First Date
how to check the second date is less than first date if the sceond date is less than first date . it should return a error .

Date & Time Fields To Printed Date/time
How can i take data from date and time field and convert:

2003-02-26 to 26th of Febuary 2003

And: 19:25:00 to 7:25 PM

Database Search -text Database...
Can anybody tell me how to search a flat file database delimited by |. I have exploded the data and managed to get it into a table but want to restrict the final table contents by a search.

The table code at the moment is below - I'd be using a htm file to submit the data. and hopefully be able to search by partial searches eg big would return big and bigfoot. Code:

Date() Help
Here's my question. I made an litle calendar that displays the days of the month. if in a certain day i have something booked it displays a link to the day information.

Php Date
I get the todays date- yesterdays date and tomorrows date, like so:

$yesterday = date ("Y-m-d", mktime (0,0,0,date("m"),(date("d")-1),date("Y")));

$tomorrow = date ("Y-m-d", mktime (0,0,0,date("m"),(date("d")+1),date("Y")));

$actualdate = date("Y-m-d");

Which returns the date in the format "200-11-13" But I need to add 13 hours to all three - how owuld I do this?

Date
i still have the problem with daylight saving last Sun of March will increase 1 hour of the normal time and first Sun of Oct will set back to normal time: I try date("I") and it's doesn't work.


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