Re: [PHP-DB] Date formatting question

2009-04-08 Thread Phpster

See the date function

Http://www.php.net/date

Bastien

Sent from my iPod

On Apr 8, 2009, at 21:41, Jack Lauman  wrote:

I need to reformat the output of the 'dates' field from '2009-04-08'  
to 'Wed. Apr. 8th'. Any help would be appreciated.


Thanks.

---

for ($counter = 0; $counter < mysql_num_rows($resultID); $counter++);

while ($row = mysql_fetch_object($resultID))
{
   print "";
   print "" . $row->dates . "";
   print "" . $row->times . "";
   print "" . $row->am_pm . "";
   print "" . $row->height . "";
   print "" . $row->cond . "";
   print "";
}


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date formatting question

2009-04-08 Thread Chris

Jack Lauman wrote:
I need to reformat the output of the 'dates' field from '2009-04-08' to 
'Wed. Apr. 8th'. Any help would be appreciated.


You can either do it using mysql date formats (see 
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format) 
or something like date('...', strtotime($result->date));


See http://php.net/date and http://php.net/strtotime

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date Translation in MySQL

2008-08-10 Thread Bastien Koert
On Tue, Aug 5, 2008 at 4:33 PM, Ben Miller <[EMAIL PROTECTED]>wrote:

> Figured there had to be an easier way.  Thank you so much.
>
> -Original Message-
> From: Simcha Younger [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 05, 2008 2:48 PM
> To: php-db@lists.php.net
> Subject: RE: [PHP-DB] Date Translation in MySQL
>
>
> Select * FROM ... WHERE DAYOFWEEK(datecol)=7
>
> -Original Message-
> From: Ben Miller [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 05, 2008 8:10 PM
> To: PHP. DB Mail List
> Subject: [PHP-DB] Date Translation in MySQL
>
> I'm looking for a quick and simple way to query a MySQL database by date,
> or
> more specifically, by day of the week.  My dates are stored in the DB in
> -MM-DD HH:MM:SS format.  Question, is there a built-in for PHP or MySQL
> that will take this column and return only Saturdays, for example, without
> having to use PHP to find each of the last X number of Saturdays and then
> for each Saturday, query the database?
>
> In case it matters, I am running on PHP v 4.4.7 and MySQL version 4.1.22.
>
> Thanks in advance.
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> No virus found in this incoming message.
> Checked by AVG - http://www.avg.com
> Version: 8.0.138 / Virus Database: 270.5.12/1592 - Release Date: 05/08/2008
> 06:03
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Also look at the mysql DATE_FORMAT function

-- 

Bastien

Cat, the other other white meat


RE: [PHP-DB] Date Translation in MySQL

2008-08-05 Thread Ben Miller
Figured there had to be an easier way.  Thank you so much.

-Original Message-
From: Simcha Younger [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 05, 2008 2:48 PM
To: php-db@lists.php.net
Subject: RE: [PHP-DB] Date Translation in MySQL


Select * FROM ... WHERE DAYOFWEEK(datecol)=7

-Original Message-
From: Ben Miller [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 05, 2008 8:10 PM
To: PHP. DB Mail List
Subject: [PHP-DB] Date Translation in MySQL

I'm looking for a quick and simple way to query a MySQL database by date, or
more specifically, by day of the week.  My dates are stored in the DB in
-MM-DD HH:MM:SS format.  Question, is there a built-in for PHP or MySQL
that will take this column and return only Saturdays, for example, without
having to use PHP to find each of the last X number of Saturdays and then
for each Saturday, query the database?

In case it matters, I am running on PHP v 4.4.7 and MySQL version 4.1.22.

Thanks in advance.



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.138 / Virus Database: 270.5.12/1592 - Release Date: 05/08/2008
06:03


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Date Translation in MySQL

2008-08-05 Thread Simcha Younger
Select * FROM ... WHERE DAYOFWEEK(datecol)=7

-Original Message-
From: Ben Miller [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 05, 2008 8:10 PM
To: PHP. DB Mail List
Subject: [PHP-DB] Date Translation in MySQL

I'm looking for a quick and simple way to query a MySQL database by date, or
more specifically, by day of the week.  My dates are stored in the DB in
-MM-DD HH:MM:SS format.  Question, is there a built-in for PHP or MySQL
that will take this column and return only Saturdays, for example, without
having to use PHP to find each of the last X number of Saturdays and then
for each Saturday, query the database?

In case it matters, I am running on PHP v 4.4.7 and MySQL version 4.1.22.

Thanks in advance.



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

No virus found in this incoming message.
Checked by AVG - http://www.avg.com 
Version: 8.0.138 / Virus Database: 270.5.12/1592 - Release Date: 05/08/2008
06:03


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date calculation from MySql table

2008-04-12 Thread Evert Lammerts

Something like this should work.

$today = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
$tomorrow = mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"));
$sql = "SELECT COUNT(*) FROM table WHERE regdate BETWEEN {$today} AND 
{$tomorrow}";


$thismonth = mktime(0, 0, 0, date("m"), 1, date("Y"));
$nextmonth = mktime(0, 0, 0, date("m") + 1, 1, date("Y"));
$sql = "SELECT COUNT(*) FROM table WHERE regdate BETWEEN {$thismonth} 
AND {$nextmonth}";


$thisyear = mktime(0, 0, 0, 1, 1, date("Y"));
$nextyear = mktime(0, 0, 0, 1, 1, date("Y") + 1);
$sql = "SELECT COUNT(*) FROM table WHERE regdate BETWEEN {$thisyear} AND 
{$nextyear}";


HOWEVER, consider to use the mysql date functions instead of a unix 
timestamp.


A. Joseph wrote:

I want to calculate the registed users today
Also total users this week
Total users this month
Total users this year

The Mysql table has a row of INT(11) with time() value inserted.

I did something like this
$today = strtotime("+1 day")
Then $sql = "SELECT COUNT(*) FROM table WHERE dateReg <= $today";

Same with year/months also, only I use strtotime("+1 week) for a week,
strtotime("+1 month) for a month,

Can someone help me with this calculation?

On 4/7/08, Bruno Lustosa <[EMAIL PROTECTED]> wrote:
  

On Mon, Apr 7, 2008 at 2:42 PM, Dee Ayy <[EMAIL PROTECTED]> wrote:


 I was thinking of using output buffering and then making 1 call to
 utf8_encode, but I think a better question is, how do I stop using
 utf8_encode completely?
  

If all components are using utf-8, you should have no problems with
charsets at all. By all components, I mean:
- Script files in utf-8;
- Database in utf-8;
- Database connection using utf-8;
- Content-type header set to utf-8.
With all these, you're free of charset hell, and can enjoy the beauty
of utf-8 completely without problems.



 The rendered view I see in Firefox 2.0.0.12 is a question mark "?"
 where the French character should have appeared.  If I use
 utf8_encode, the character appears as it should.
  

Question mark means the character is not utf-8. Check where it comes
from. Might be the database or the way you are connecting to it. I
don't know much about mysql, I use postgresql. With it, you just have
to call pg_set_client_encoding() to make the connection in utf-8 mode,
and "create database with encoding='unicode'" to set up a database
using utf-8.



 Luckily I'm on PHP 4.3.10, so I can't see what mb_check_encoding would
 report -- if that would even help normally.
  

Shouls upgrade to PHP 5. PHP 4 is way out of date, is not getting
updates anymore, and will not even get security bugfixes after august
8th. It's been almost 4 years since PHP 5 was released.

http://www.php.net/archive/2007.php

Check the PHP 4 end of life announcement.

--
Bruno Lustosa <[EMAIL PROTECTED]>
ZCE - Zend Certified Engineer - PHP!
http://www.lustosa.net/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






  



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] date format problem

2007-12-22 Thread Bastien Koert

www.php.net/date will show you all the possibilities of formatting the date

bastien

> Date: Sat, 22 Dec 2007 17:54:07 +0600
> From: [EMAIL PROTECTED]
> To: php-db@lists.php.net
> Subject: [PHP-DB] date format problem
> 
> my problem  is with date format
> 
> mysql support  -mm-dd
> 
> but my client not use to enter date in -mm-dd  format
> he use to in  dd-mm-yyy   format
> 
> how can it possible to input date in
> dd-mm- format

_
Use fowl language with Chicktionary. Click here to start playing!
http://puzzles.sympatico.msn.ca/chicktionary/index.html?icid=htmlsig
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date problems

2007-09-12 Thread Jürgen Wind

you can mimic the old behaviour like so:
select TS, 1*TS as OldStyle;
(TS being your timestamp filed)

TS |OldStyle
2007-09-03 15:03:02 |   20070903150302


rDubya wrote:
> 
> WOW!!  Thanks for all the help guys!!  And Instruct ICC.. you're
> solution for pulling the events did work.. but..  it turns out that
> the solution was actually much simpler than I thought:
> 
> The old mysql database (once again, not sure what version) stored the
> date as MMDDHHMMSS.  The new database stores the date as
> -MM-DD HH:MM:SS.  All I had to do was adjust my code to pull only
> the values and none of the delimeters (ie. "-", " ", and ":").
> DUH!!!
> 
> But once again, thanks you guys for all the help
> 
> 
> rDubya
> 
> 
> On 9/7/07, Instruct ICC <[EMAIL PROTECTED]> wrote:
>> >From: "Instruct ICC" <[EMAIL PROTECTED]>
>> >And while not trusting your indexing, rewrite short_date as:
>> My short_date rewrite was also wrong.  So it looks like you will have to
>> learn those offsets for this function if you do it on the PHP side.  But
>> you
>> could also do it on the MySQL side.
>>
>> _
>> Get a FREE small business Web site and more from Microsoft(r) Office
>> Live!
>> http://clk.atdmt.com/MRT/go/aub0930003811mrt/direct/01/
>>
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/date-problems-tf4393599.html#a12634947
Sent from the Php - Database mailing list archive at Nabble.com.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date problems

2007-09-07 Thread rDubya
WOW!!  Thanks for all the help guys!!  And Instruct ICC.. you're
solution for pulling the events did work.. but..  it turns out that
the solution was actually much simpler than I thought:

The old mysql database (once again, not sure what version) stored the
date as MMDDHHMMSS.  The new database stores the date as
-MM-DD HH:MM:SS.  All I had to do was adjust my code to pull only
the values and none of the delimeters (ie. "-", " ", and ":").
DUH!!!

But once again, thanks you guys for all the help


rDubya


On 9/7/07, Instruct ICC <[EMAIL PROTECTED]> wrote:
> >From: "Instruct ICC" <[EMAIL PROTECTED]>
> >And while not trusting your indexing, rewrite short_date as:
> My short_date rewrite was also wrong.  So it looks like you will have to
> learn those offsets for this function if you do it on the PHP side.  But you
> could also do it on the MySQL side.
>
> _
> Get a FREE small business Web site and more from Microsoft(r) Office Live!
> http://clk.atdmt.com/MRT/go/aub0930003811mrt/direct/01/
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date problems

2007-09-07 Thread Graham Cossey
"This DID work, but I recently switched hosting companies..."

Is the new server in a different country with a different date format
/ time zone?

Just a thought  ;-\

On 9/7/07, Instruct ICC <[EMAIL PROTECTED]> wrote:
> >From: "Instruct ICC" <[EMAIL PROTECTED]>
> >And while not trusting your indexing, rewrite short_date as:
> My short_date rewrite was also wrong.  So it looks like you will have to
> learn those offsets for this function if you do it on the PHP side.  But you
> could also do it on the MySQL side.
>
> _
> Get a FREE small business Web site and more from Microsoft(r) Office Live!
> http://clk.atdmt.com/MRT/go/aub0930003811mrt/direct/01/
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Graham

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date problems

2007-09-07 Thread Instruct ICC

From: "Instruct ICC" <[EMAIL PROTECTED]>
And while not trusting your indexing, rewrite short_date as:
My short_date rewrite was also wrong.  So it looks like you will have to 
learn those offsets for this function if you do it on the PHP side.  But you 
could also do it on the MySQL side.


_
Get a FREE small business Web site and more from Microsoft® Office Live! 
http://clk.atdmt.com/MRT/go/aub0930003811mrt/direct/01/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date problems

2007-09-07 Thread Instruct ICC

From: rDubya <[EMAIL PROTECTED]>

Thanks for the help so far guys!!

Not helping though.  I have the date contained in the database as timestamp
(-MM-DD HH:MM:SS).


Do you really need to pull events from the database which are not in your 
range of interest?  This will only slow down your processing time.  Instead, 
you could be looping over valid events and not using your incorrect 
check_date function.


If you insist upon using a check_date function on the PHP side (which you 
claimed to have worked in the past), on the format -MM-DD HH:MM:SS where 
the first Y is at index 0, then substr($mysql_timestamp, 4, 2) is not the 
month "MM", it is "-M".  You need 5,2.  Your other offsets are also wrong.  
Rather than debugging your check_date function, you should just pull the 
info you actually need from the database (even to the point of not selecting 
*, and instead naming specific fields if you really don't need all fields), 
and remove your check_date function.  Then your while loop will loop over 
only valid events.


Also, although this doesn't affect the running of your code, your variable 
names show a misunderstanding of what parameters you are passing and 
receiving.


$sql = "SELECT...";
$resultResource = mysql_query($sql);// or just $result = mysql_query($sql);
if($result != false){
  while($event_data = mysql_fetch_assoc($result)) {
 //Do something with a valid event instead of checking if it is valid 
now on the PHP side.

  }
}

Too bad you are not on MySQL 5, because the SQL query could have been even 
closer to the phrasing you posted to the list "it is between now and three 
weeks from now", similar to Mike's reply as:

$sql = "SELECT * FROM `EVENTS`
WHERE `event_city` = '" . $city . "'
AND `theEventDate` BETWEEN NOW() AND DATE_ADD( NOW(), INTERVAL 3 WEEK)
ORDER BY `theEventDate` ASC";

But for your MySQL version, WEEK is unavailable and you need INTERVAL 21 DAY
(watch the unit versus the expr; DAY not DAYS -- WEEK not WEEKS)
http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#function_date-add
http://dev.mysql.com/doc/refman/4.1/en/comparison-operators.html

But if you are not familiar with BETWEEN or DATE_ADD, then the way I posted 
is another way to skin this cat.


$sql = "SELECT * FROM `EVENTS`
WHERE `event_city` = '" . $city . "'
AND TO_DAYS( `theEventDate` ) >= TO_DAYS( NOW() )
AND TO_DAYS( `theEventDate` ) <= TO_DAYS( NOW() ) + 21
ORDER BY `theEventDate` ASC";

http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#function_to-days

And while not trusting your indexing, rewrite short_date as:
function short_date ($mysql_timestamp) {
   return date("D M j", $mysql_timestamp);
}

or this is probably a 1-liner in the while loop:
while...//I'm already using valid events due to my query
  ... date("D M j", $event_data['theEventDate']) ...

_
Test your celebrity IQ.  Play Red Carpet Reveal and earn great prizes! 
http://club.live.com/red_carpet_reveal.aspx?icid=redcarpet_hotmailtextlink2


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date problems

2007-09-06 Thread rDubya
Thanks for the help so far guys!!

Not helping though.  I have the date contained in the database as timestamp
(-MM-DD HH:MM:SS).  The problem is that not only is it not displaying
events, but if I alter my code so that it displays ALL events, it shows the
events for the last year, and those upcoming, as all being in the first
couple weeks of December, 2006.

Here is the script in action: http://www.clubandpub.ca/lobby/?city=1

The events SHOULD display on the right column, under where it says events.
If you click to the GUIDE page, the calendar should be highlighted on the
dates where there are events, and the events in the coming weeks (as well as
concerts) should display below that (under their respective headings).

This DID work, but I recently switched hosting companies as the one I was
with has become increasingly unreliable after the company changed hands.  My
new server uses PHP 5 server, with MySQL 4.1 (I'm not 100% sure what the old
was.. I think it was PHP 4, and while I think it was the same MySQL version,
it could have been an earlier one).

Cheers!

rDubya

also, here is the code that actually displays the events:




it then displays the event information of the events within that time period
(pulled from the database, with the date being displayed using the
short_date function posted earlier)





On 9/6/07, Mike Gohlke <[EMAIL PROTECTED]> wrote:
>
> Argh, make sure you add the closing paren for the date_add since I
> forgot it.
>
> Mike...
>
> Mike Gohlke wrote:
> > It's much better to use add_date instead of to_days since mysql isn't
> > smart enough to do it for you.
> > Such as:
> > SELECT yourEventFields FROM theTable
> > WHERE theEventDate BETWEEN now() AND date_add(now(), INTERVAL 21 DAYS;
> >
> > This way mysql will calc the now() and date_add and will essentially
> > convert them to static values.  If there's an index on theEventDate it
> > will be used.
> >
> > Mike...
> >
> > Instruct ICC wrote:
> >>> From: rDubya <[EMAIL PROTECTED]>
> >>> My problem is that I have events dated for Sep 2007 and on, and yet
> >>> they all come up as being on Dec 7 to 9, 2006..  any ideas?
> >>>
> >>> rDubya
> >>
> >> How about having MySQL only return the events you are interested in?
> >>
> >> SELECT yourEventFields FROM theTable
> >> WHERE
> >> TO_DAYS( theEventDate ) >= TO_DAYS( NOW() )
> >> AND
> >> TO_DAYS( theEventDate ) <= TO_DAYS( NOW() ) + 21
> >>
> >> I like theEventDate to be in the format -MM-DD
> >>
> >>
> http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days
> >>
> >>
> >> _
> >> A place for moms to take a break!
> >> http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us
> >>
> >
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP-DB] date problems

2007-09-06 Thread Mike Gohlke
Argh, make sure you add the closing paren for the date_add since I 
forgot it.


Mike...

Mike Gohlke wrote:
It's much better to use add_date instead of to_days since mysql isn't 
smart enough to do it for you.

Such as:
SELECT yourEventFields FROM theTable
WHERE theEventDate BETWEEN now() AND date_add(now(), INTERVAL 21 DAYS;

This way mysql will calc the now() and date_add and will essentially 
convert them to static values.  If there's an index on theEventDate it 
will be used.


Mike...

Instruct ICC wrote:

From: rDubya <[EMAIL PROTECTED]>
My problem is that I have events dated for Sep 2007 and on, and yet
they all come up as being on Dec 7 to 9, 2006..  any ideas?

rDubya


How about having MySQL only return the events you are interested in?

SELECT yourEventFields FROM theTable
WHERE
TO_DAYS( theEventDate ) >= TO_DAYS( NOW() )
AND
TO_DAYS( theEventDate ) <= TO_DAYS( NOW() ) + 21

I like theEventDate to be in the format -MM-DD

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days 



_
A place for moms to take a break! 
http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us






--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date problems

2007-09-06 Thread Mike Gohlke
It's much better to use add_date instead of to_days since mysql isn't 
smart enough to do it for you.

Such as:
SELECT yourEventFields FROM theTable
WHERE theEventDate BETWEEN now() AND date_add(now(), INTERVAL 21 DAYS;

This way mysql will calc the now() and date_add and will essentially 
convert them to static values.  If there's an index on theEventDate it 
will be used.


Mike...

Instruct ICC wrote:

From: rDubya <[EMAIL PROTECTED]>
My problem is that I have events dated for Sep 2007 and on, and yet
they all come up as being on Dec 7 to 9, 2006..  any ideas?

rDubya


How about having MySQL only return the events you are interested in?

SELECT yourEventFields FROM theTable
WHERE
TO_DAYS( theEventDate ) >= TO_DAYS( NOW() )
AND
TO_DAYS( theEventDate ) <= TO_DAYS( NOW() ) + 21

I like theEventDate to be in the format -MM-DD

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days 



_
A place for moms to take a break! 
http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] date problems

2007-09-06 Thread Instruct ICC

From: rDubya <[EMAIL PROTECTED]>
My problem is that I have events dated for Sep 2007 and on, and yet
they all come up as being on Dec 7 to 9, 2006..  any ideas?

rDubya


How about having MySQL only return the events you are interested in?

SELECT yourEventFields FROM theTable
WHERE
TO_DAYS( theEventDate ) >= TO_DAYS( NOW() )
AND
TO_DAYS( theEventDate ) <= TO_DAYS( NOW() ) + 21

I like theEventDate to be in the format -MM-DD

http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_to-days

_
A place for moms to take a break! 
http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date problem

2007-01-21 Thread Miles Thompson

At 12:26 PM 1/21/2007, Denis L. Menezes wrote:


Dear friends.

I have a date field in mysql called event_end .

I want to run a query to find all records where the event_and is greater
than today's date. I have written the following code. It does not work.
Please point out the mistake.

$today = getdate();
 $sql="select * from events where event_end>'.$today.' order by event_start
Asc ";


Thanks
denis


How is your date formatted in the database.

Compare  that to the format returned by getdate(), then consider using 
date('Y-m-d'). That's assuming your MySQL date is stored as -mm-dd.


Nonetheless, this should set you on the right road.

It would also have helped your diagnosis if you echoed your SQL statement.

Cheers - Miles Thompson




--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.410 / Virus Database: 268.17.3/642 - Release Date: 1/20/2007

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date Conversion in RFC822 format

2006-05-18 Thread Stut

Manoj Singh wrote:

I am developing a site in php implementing the concept of rss feeds. For
that i want to convert the standard date into RFC822 format.

If any one have idea about it, please help me.


Go to http://php.net/date and search the page for RFC822. If you need 
further help read the rest of that page.


-Stut

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Date Conversion

2006-05-16 Thread Ralph Brickley
ADDENDUM:

To Convert your date string, use the associate array:
$months_arr = array("January"=>01, "February
=>02...);

$month = $months_arr["February"];

* Replace $months_arr["February"] with $_POST["Month"];

// Output
$month = 01;



Ralph Brickley

-Original Message-
From: Ralph Brickley [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 16, 2006 1:29 PM
To: [EMAIL PROTECTED]; 'Php-Db'
Subject: RE: [PHP-DB] Date Conversion

A simple associate array would work as well, although not quite as elegent.
$months_arr = array("January"=>01, "February"=>02...);

-Original Message-
From: Mark Bomgardner [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 16, 2006 12:35 PM
To: Php-Db
Subject: [PHP-DB] Date Conversion

PHP 4.4/MySQL 4.0

I am tying to convert a date to put into a database from a string (ie: 
January, February) to a numeric value (ie: 01,02).  I am taking the 
value from a form, which is a drop down menu listing the months.

$sMonth1 = $_POST['Smonth']; returns the money selected from the form.
When I go to format the month from a string to numeric with 
date('m',strtotime($sMonth1));
it returns 12, no matter which month I select.

In reading the docs at php.net, date('m',strtotime($sMonth1)); is 
correct to reformat from a string to a time format.

What am I missing.


mark bomgardner

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Date Conversion

2006-05-16 Thread Ralph Brickley
A simple associate array would work as well, although not quite as elegent.
$months_arr = array("January"=>01, "February"=>02...);

-Original Message-
From: Mark Bomgardner [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 16, 2006 12:35 PM
To: Php-Db
Subject: [PHP-DB] Date Conversion

PHP 4.4/MySQL 4.0

I am tying to convert a date to put into a database from a string (ie: 
January, February) to a numeric value (ie: 01,02).  I am taking the 
value from a form, which is a drop down menu listing the months.

$sMonth1 = $_POST['Smonth']; returns the money selected from the form.
When I go to format the month from a string to numeric with 
date('m',strtotime($sMonth1));
it returns 12, no matter which month I select.

In reading the docs at php.net, date('m',strtotime($sMonth1)); is 
correct to reformat from a string to a time format.

What am I missing.


mark bomgardner

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date Conversion

2006-05-16 Thread Brad Bonkoski



Mark Bomgardner wrote:


PHP 4.4/MySQL 4.0

I am tying to convert a date to put into a database from a string (ie: 
January, February) to a numeric value (ie: 01,02).  I am taking the 
value from a form, which is a drop down menu listing the months.


$sMonth1 = $_POST['Smonth']; returns the money selected from the form.
When I go to format the month from a string to numeric with 
date('m',strtotime($sMonth1));

it returns 12, no matter which month I select.

In reading the docs at php.net, date('m',strtotime($sMonth1)); is 
correct to reformat from a string to a time format.


What am I missing.


mark bomgardner


An idea along a different path would be
for your original select box where you pick the month do something like 
this:

January
Febuary


Then the value passed to your form will be the numeric representation of 
the month so there will be no need to translate the String --> number..


HTH
-Brad

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date question

2006-03-17 Thread Gerry Danen
This works perfect, Bastien!

Many thanks.

Gerry

On 3/13/06, Bastien Koert <[EMAIL PROTECTED]> wrote:
>
> select * from table where date_format(date_field, '%Y-%m') = '2006-02'
>
>
> bastien
>
>
> >From: "Gerry Danen" <[EMAIL PROTECTED]>
> >To: php-db@lists.php.net
> >CC: [EMAIL PROTECTED]
> >Subject: [PHP-DB] Date question
> >Date: Sun, 12 Mar 2006 20:44:13 -0700
> >
> >While I am rebuilding my crashed laptop (the machine that had all my
> >intelligence), I started thinking about a select statement I need.
> >
> >I have log info in a table and want to extract it on a monthly basis. The
> >date field is in -mm-dd format. What's a good way to select those
> dates
> >that match 2006-02, for example.
> >
> >I apologize if the solution should be staring me in the face, but all my
> >favorites and help files are toast, until I can restore some of them.
>


RE: [PHP-DB] Date question

2006-03-13 Thread Bastien Koert

select * from table where date_format(date_field, '%Y-%m') = '2006-02'


bastien



From: "Gerry Danen" <[EMAIL PROTECTED]>
To: php-db@lists.php.net
CC: [EMAIL PROTECTED]
Subject: [PHP-DB] Date question
Date: Sun, 12 Mar 2006 20:44:13 -0700

While I am rebuilding my crashed laptop (the machine that had all my
intelligence), I started thinking about a select statement I need.

I have log info in a table and want to extract it on a monthly basis. The
date field is in -mm-dd format. What's a good way to select those dates
that match 2006-02, for example.

I apologize if the solution should be staring me in the face, but all my
favorites and help files are toast, until I can restore some of them.

TIA.

Gerry


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date question

2006-03-12 Thread Chris

Gerry Danen wrote:

While I am rebuilding my crashed laptop (the machine that had all my
intelligence), I started thinking about a select statement I need.

I have log info in a table and want to extract it on a monthly basis. The
date field is in -mm-dd format. What's a good way to select those dates
that match 2006-02, for example.

I apologize if the solution should be staring me in the face, but all my
favorites and help files are toast, until I can restore some of them.


Which database are you using?

Mysql has this: 
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html


Postgresql has:
http://www.postgresql.org/docs/8.1/static/functions-datetime.html

I'm sure others have the same sort of functionality.

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date question

2006-03-12 Thread LJ Regalado
For example, you have table `logs` with `datelog` field and you want to
select dates
that match 2006-02. You can try this select statement:

SELECT * FROM `logs` WHERE MONTH(datelog)='02' and YEAR(datelog)='2006'

Hope that helps.

LJ Regalado


RE: [PHP-DB] Date & Time 90 minutes ago

2006-01-19 Thread tg-php
Bastien's example is probably the quickest and easiest.  I just wanted to point 
out that you can use math within the mktime() function as well in case the 
relative date/time you need isn't "right now".

$month = 1;
$day = 19;
$year = 2006;
$hour = 17;
$minute = 08;
$second = 05;

echo date("Y-m-d H:i:s", mktime($hour, $minute - 90, $second, $month, $day, 
$year));

It will even adjust for leap years I believe.  You can add/subtract/etc any of 
those items and it's smart enough to figure out what the correct resulting 
date/time would be.

-TG


= = = Original message = = =



bastien


>From: "Ron Piggott (PHP)" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: PHP DB 
>Subject: [PHP-DB] Date & Time 90 minutes ago
>Date: Thu, 19 Jan 2006 16:57:33 -0500
>
>Would someone be able to help me with the DATE command syntax to know
>what the date and time was 90 minutes ago?  I am trying to assign these
>values into two variables:
>
>$date_90_minutes_ago
>$time_90_minutes_ago
>
>I am not sure how to handle midnight where if the time is 00:10:00
>ninety minutes earlier is a day before.  Thanks.  Ron
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date & Time 90 minutes ago

2006-01-19 Thread Cal Evans

$date_90_minutes_ago = date('m/d/Y',mktime()-(60*90));
$time_90_minutes_ago = date('h:i:s',mktime()-(60*90));

60 seconds * 90 minutes.
=C=
|
| Cal Evans
| http://www.calevans.com
|
| We get our best customers from referrals.
| We would appreciate you referring any of your
| friends or co-workers that need web hosting.
|
|

Ron Piggott (PHP) wrote:

Would someone be able to help me with the DATE command syntax to know
what the date and time was 90 minutes ago?  I am trying to assign these
values into two variables:

$date_90_minutes_ago
$time_90_minutes_ago

I am not sure how to handle midnight where if the time is 00:10:00
ninety minutes earlier is a day before.  Thanks.  Ron



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Date & Time 90 minutes ago

2006-01-19 Thread Bastien Koert



bastien



From: "Ron Piggott (PHP)" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: PHP DB 
Subject: [PHP-DB] Date & Time 90 minutes ago
Date: Thu, 19 Jan 2006 16:57:33 -0500

Would someone be able to help me with the DATE command syntax to know
what the date and time was 90 minutes ago?  I am trying to assign these
values into two variables:

$date_90_minutes_ago
$time_90_minutes_ago

I am not sure how to handle midnight where if the time is 00:10:00
ninety minutes earlier is a day before.  Thanks.  Ron

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date Formatting Question

2005-12-14 Thread tg-php
You got the right idea, but you're making it more complicated than it needs to 
be.

your $sDate after using explode() is going to contain an array.  strtotime 
doesn't take an array, it takes a string.

$monthName = date("F", strtotime($row_events['Sdate']));
$monthNumber = date("m",  strtotime($row_events['Sdate']));
// or "n" if you want "1" instead of "01" for January

echo "\n";
for ($i = 1; $i <= 12; $i++) 

  // using date() below to get month name, day and year irrelevant
  $selectMonthText = date("F", mktime(0, 0, 0, $i, 1, 2000));

  if ($i == $monthNumber) 
$selected = " SELECTED";
   else 
$selected = "";
  
  echo "$selectMonthText\n";

echo "\n";


-TG


= = = Original message = = =

I am trying to format the month portion of a date that I am trying to
pull from MySQL to be placed into a drop down menu to modify the date.
I have tried several ways and none seem to be working.  

I am pulling the date out of MySQL with: 
$sDate = explode("-", $row_events['Sdate']);

And then attempting to insert each portion of the array into a drop down
menu with:
echo "";
echo "$sDate[1]";
which is where I am running into the problem.  I pull out the month as 2
digit numeric 01, 02, 03 etc., but I want it displayed as January,
February, March, etc.,

I have tried the following with no success:
Date("F",strtotime($sDate));  
Strftime("%B:,$sDate);
Date("F",$sDate);


I would use MySQL to format the date, but I have three date fields to
modify and it would be easier to do it in PHP

Any pointers would be appreciated.


Mark Bomgardner
Technology Specialist
KLETC


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] DATE(r)

2005-09-09 Thread Jordan Miller

You need to use:
date('Y-m-d H:i:s');

It's in the comments at:
http://www.php.net/date

Jordan



On Sep 9, 2005, at 12:52 PM, Ron Piggott wrote:



Question:

I am trying to for the first time create a table with a column that is
defined as datetime

I wanted to populate that column with the date(r) command.

date(r) on my web site gives this response:

Fri, 9 Sep 2005 13:32:19 -0400

How may I manipulate date(r) to give a format which is compatable  
to the

column type

-00-00 00:00:00
-MM-DD 24:59:59

Ron

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php







--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] DATE(r)

2005-09-09 Thread Bastien Koert

use timestamp column type and populate it by

$date = strtottime(date(r));

then when you want to display it

$date = date('r',$row['datefieldname']);

Bastien



From: "Ron Piggott" <[EMAIL PROTECTED]>
Reply-To: "Ron Piggott" <[EMAIL PROTECTED]>
To: "PHP DB" 
Subject: [PHP-DB] DATE(r)
Date: Fri, 9 Sep 2005 12:52:59 -0500

Question:

I am trying to for the first time create a table with a column that is
defined as datetime

I wanted to populate that column with the date(r) command.

date(r) on my web site gives this response:

Fri, 9 Sep 2005 13:32:19 -0400

How may I manipulate date(r) to give a format which is compatable to the
column type

-00-00 00:00:00
-MM-DD 24:59:59

Ron

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date problem again ;-)

2005-03-22 Thread Forest Liu
I suppose there is a " submit_time" field in your DB table, so you could:
"SELECT * FROM `tablename` WHERE `submit_time`>=".lastdays(3)

lastdays() is a function you could create using mktime(),time(), and date()


On Tue, 22 Mar 2005 16:28:39 -0500, Chris Payne <[EMAIL PROTECTED]> wrote:
> Hi there everyone,
> 
> OK I'm using the following in my query to display entries in the LAST 3
> days:
> 
> DATE_SUB(CURDATE(),INTERVAL 3 DAY) <= ListingDate
> 
> But it doesn't seem to affect the results, the date format in my DB column
> (ListingDate - datatype is Date) is 2000-00-00 as in year, month and date -
> is THAT the problem?  That it needs to be an actual timestamp?  If that is
> the case I'm not sure how to approach this because the data MUST be in the
> above format as it comes from a central DB every night.  All I need to do is
> display the current date plus also the previous x amount of days in between.
> 
> I'm using PHP 4 with MySQL 4.0.22 (Not the latest MySQL I know, sigh).
> 
> 
> Chris
> 
> 


-- 
   Sincerely,
 Forest Liu(åäè)

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date conversions

2004-12-16 Thread tg-php
Interesting use of split().. don't think I've ever used that function but looks 
like it'll do just as well and also allow multiple dividers.  Thanks for 
pointing that out.

As for this:

$mysqldate = $y.'-'.$m.'-'.$d;


The only problem I foresee is what happens when you have single digit days and 
months?

2004-9-8

What does MySQL do with this?

What happens if you want the date in another format?  It'll take another minute 
or two (and leave more potential for typing errors I think) if you did your 
date format like this rather than using date() + mktime().   I think 
date/mktime gives you more reliability and more flexibility.   Just something 
to think about.  When it comes down to it, whatever works for you, right? :)

-TG

= = = Original message = = =

Thank you for all your help.

Among all  the variations I found this to be the clearest:

list($d,$m,$y) = explode("/",$testdate);
$mysqldate = date("Y-m-d", mktime(0,0,0,$m,$d,$y));

But I also thought the use of split instead of explode so you could nominate
multiple delimiters was good.
eg.
list($d,$m,$y) = split('[/.-]', $testdate);

Another variation was to hardcode the date results instead of using the date
function which is very simple:
eg.
$mysqldate = $y.'-'.$m.'-'.$d;

Sorry for asking a question that is obviously asked often.

Interesting comment on 'normal'. I suspect that numerically more of the
world uses dmy than mdy. There is a lot more of the world outside the US
than in it.

Thanks again for all your help.

Neil


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] date conversions

2004-12-16 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 16 December 2004 06:00, neil wrote:

> Hi
> 
> I am needing to convert a d/m/y date such as 30/11/2004 into the
> format that mysql can use ie. 2004-11-20
> 
> If I try the following:
> 
> $testdate="30/11/2004";
> echo date("Y-m-d", strtotime($testdate));
> 
> the result is - 2006-06-11

strtotime() is, unfortunately, a little American biased and only recognises
the mm/dd/ numeric format (using slashes).  So the above is returning
the equivalent of the 11th day of the 30th month of 2004!

You can use other PHP functions, as has been suggested, but you might also
investigate the mySQL date formatting functions, as I believe they work
perfectly well on input dates as well as output ones.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date conversions

2004-12-15 Thread neil
Thank you for all your help.

Among all  the variations I found this to be the clearest:

list($d,$m,$y) = explode("/",$testdate);
$mysqldate = date("Y-m-d", mktime(0,0,0,$m,$d,$y));

But I also thought the use of split instead of explode so you could nominate
multiple delimiters was good.
eg.
list($d,$m,$y) = split('[/.-]', $testdate);

Another variation was to hardcode the date results instead of using the date
function which is very simple:
eg.
$mysqldate = $y.'-'.$m.'-'.$d;

Sorry for asking a question that is obviously asked often.

Interesting comment on 'normal'. I suspect that numerically more of the
world uses dmy than mdy. There is a lot more of the world outside the US
than in it.

Thanks again for all your help.

Neil


<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Yeah, this is my problem with relyinig on strtotime().  If you don't give
it a format that it knows, it's going to give you random results (well, not
random, but "undesireable").  Seems like more of a crutch that leaves too
much chance of error for my taste.  I prefer to be a little more explicit:
>
>
> $testdate="30/11/2004";
> list($day,$month,$year) = explode("/",$testdate);
> echo date("Y-m-d", mktime(0,0,0,$month,$day,$year));
>
> Try that out.  mktime() produces a serial date/time just like strtotime()
but you have a little more control over what it's producing and subsequently
what gets piped into date().  This exact example is what I used once before
when arguing against using strtotime().  Most people are going to use a
'normal' format that strtotime() likes, but the format you're using
(european standard?) and just using the numbers is the one big instance that
strtotime() breaks.
>
> Hope this helps.  You should be able to get whatever date format you need
now.
>
> -TG
>
> *** new email address [EMAIL PROTECTED]
> *** old email address [EMAIL PROTECTED] YAY CHAPTER 11!  :(
>
>
>
>
> = = = Original message = = =
>
> Hi
>
> I am needing to convert a d/m/y date such as 30/11/2004 into the format
that
> mysql can use ie. 2004-11-20
>
> If I try the following:
>
> $testdate="30/11/2004";
> echo date("Y-m-d", strtotime($testdate));
>
> the result is - 2006-06-11
>
> I can't find any other function apart from strtotime to do this.
>
> Any ideas?
>
> Thanks
> Neil
>
>
> ___
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date conversions

2004-12-15 Thread Jason Wong
On Thursday 16 December 2004 14:00, neil wrote:

> I am needing to convert a d/m/y date such as 30/11/2004 into the format
> that mysql can use ie. 2004-11-20
>
> If I try the following:
>
> $testdate="30/11/2004";
> echo date("Y-m-d", strtotime($testdate));
>
> the result is - 2006-06-11
>
> I can't find any other function apart from strtotime to do this.

Use the string functions to manipulate it into the required format, explode() 
is one approach. If you're desperate search the archives, hundreds of 
variations of code to do this have been posted in the past. But it might be 
quicker to write your own than to hit upon the appropriate keywords to search 
for.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
If practice makes perfect, and nobody's perfect, why practice?
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date conversions

2004-12-15 Thread tg-php
Yeah, this is my problem with relyinig on strtotime().  If you don't give it a 
format that it knows, it's going to give you random results (well, not random, 
but "undesireable").  Seems like more of a crutch that leaves too much chance 
of error for my taste.  I prefer to be a little more explicit:


$testdate="30/11/2004";
list($day,$month,$year) = explode("/",$testdate);
echo date("Y-m-d", mktime(0,0,0,$month,$day,$year));

Try that out.  mktime() produces a serial date/time just like strtotime() but 
you have a little more control over what it's producing and subsequently what 
gets piped into date().  This exact example is what I used once before when 
arguing against using strtotime().  Most people are going to use a 'normal' 
format that strtotime() likes, but the format you're using (european standard?) 
and just using the numbers is the one big instance that strtotime() breaks.

Hope this helps.  You should be able to get whatever date format you need now.

-TG

*** new email address [EMAIL PROTECTED]
*** old email address [EMAIL PROTECTED] YAY CHAPTER 11!  :(




= = = Original message = = =

Hi

I am needing to convert a d/m/y date such as 30/11/2004 into the format that
mysql can use ie. 2004-11-20

If I try the following:

$testdate="30/11/2004";
echo date("Y-m-d", strtotime($testdate));

the result is - 2006-06-11

I can't find any other function apart from strtotime to do this.

Any ideas?

Thanks
Neil


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Date Question

2004-10-27 Thread John Holmes
Bomgardner, Mark A wrote:
I am having trouble converting a date from mm/dd/ to -mm-dd on a
user form.  I know there was post about this, but I keep getting an
error message when I try to search the archives.
I have looked at the manual, but I am not finding what I am looking for.
echo date('Y-m-d',strtotime('09/24/2004'));
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] Date Question

2004-10-27 Thread Bastien Koert
How are you trying to convert the date?
bastien

From: "Bomgardner, Mark A" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Subject: [PHP-DB] Date Question
Date: Wed, 27 Oct 2004 11:17:16 -0500
I am having trouble converting a date from mm/dd/ to -mm-dd on a
user form.  I know there was post about this, but I keep getting an
error message when I try to search the archives.

I have looked at the manual, but I am not finding what I am looking for.

Mark A. Bomgardner
Technology Specialist
KLETC

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] Date problem: data is current as of yesterday

2004-07-03 Thread Ford, Mike [LSS]
-Original Message-
From: Karen Resplendo
To: [EMAIL PROTECTED]
Sent: 02/07/04 19:36
Subject: [PHP-DB] Date problem: data is current as of yesterday

The database queries all the sources at night after everyone has gone
home. That means the data was current as of yesterday. This little
snippet below returns yesterday's date, except that the first day of the
month returns "0" for the day. Now, I know why this is happening, but I
can't find out how to fix it (in VBA or SQL Server I would just say,
"date()-1":
 
$today = getdate(); 
$month = $today['month'] ; 
$mday = $today['mday'] -1; 
$year = $today['year']; 
echo "Data is current  as of  $month $mday, $year";

--

The mktime() function is your friend for this kind of date arithmetic. For
example, this is one possible way to do what you want:

  $yesterday = mktime(12, 0, 0, $today['mon'], $today['mday']-1,
$today['year']);
  echo "Data is current as of ".date("F j, Y", $yesterday);

(Note the use of time 12:00:00 to avoid daylight savings oddities!)

The examples on the date() and mktime() manual pages may suggest other
possibilities to you.

Cheers!

Mike
 


-
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date problem: data is current as of yesterday

2004-07-02 Thread jeffrey_n_Dyke


accidentally replied only to karen.

> The database queries all the sources at night after everyone has gone
home. That means the data was current as of yesterday. This little snippet
below returns yesterday's date, except that the first day of the month
returns "0" for > the day. Now, I know why this is happening, but I can't
find out how to fix it (in VBA or SQL Server I would just > say,
"date()-1":

> $today = getdate();
> $month = $today['month'] ;
> $mday = $today['mday'] -1;
> $year = $today['year'];
> echo "Data is current  as of  $month $mday, $year";

you can do the same thing with php.

I'd use a timestamp and subtract 86400 (24 hours of seconds)

$yesterday_at_this_time = date("Y-m-d H:i:s", time() - 86400);

hth
Jeff
-
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Date problem: data is current as of yesterday

2004-07-02 Thread Neal Carmine
Use strtotime() instead..

http://us2.php.net/manual/en/function.strtotime.php

Regards,
Neal Carmine
Nine Systems Corporation


-Original Message-
From: Karen Resplendo [mailto:[EMAIL PROTECTED] 
Sent: Friday, July 02, 2004 12:36 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Date problem: data is current as of yesterday

The database queries all the sources at night after everyone has gone home.
That means the data was current as of yesterday. This little snippet below
returns yesterday's date, except that the first day of the month returns "0"
for the day. Now, I know why this is happening, but I can't find out how to
fix it (in VBA or SQL Server I would just say, "date()-1":
 
$today = getdate(); 
$month = $today['month'] ; 
$mday = $today['mday'] -1; 
$year = $today['year']; 
echo "Data is current  as of  $month $mday, $year";
 
 


-
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Date help needed

2004-06-25 Thread Kenny
Hi Neil,

I would actually like to get a sample of this code as well if you don't
mind

K-

-Original Message-
From: Neil Smith [MVP, Digital media]
[mailto:[EMAIL PROTECTED] 
Sent: 25 June 2004 16:22
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Date help needed

No, it's actually very easy to do the autocomplete once you get the hang
of 
it. Actually the way I've done it is to populate a multi-select box but
you 
could also use a DIV and write out the values

Dump the email addresses as an XML file (generate this dynamically) then

use XSLT to read out matching rows on each keyup ... basically you
filter 
the XML file each time till you get down to one value

Yes, it's javascript but it works really well as long as you have some 
control over your client browser (in the case of your boss, probably IE
but 
it can be made to work in mozilla / firefox too)

Mail me offlist if you want a working example.

Cheers - Neil

At 11:07 25/06/2004 +, you wrote:
>Message-Id: <[EMAIL PROTECTED]>
>From: "Chris Payne" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Date: Thu, 24 Jun 2004 22:53:13 -0400
>MIME-Version: 1.0
>Content-Type: text/plain;
>         charset="us-ascii"
>Content-Transfer-Encoding: 7bit
>Subject: RE: [PHP-DB] Date help needed
>
>One thing he wanted which I didn't know how to do (Javascript I guess
which
>I don't know much about) was to preload a database of email address,
and as
>he started to type an email address it would do a sort of
auto-complete, but
>have no clue how to go about that so just told him not viable ATM.



CaptionKit http://www.captionkit.com : Production tools
for accessible subtitled internet media, transcripts
and searchable video. Supports Real Player, Quicktime
and Windows Media Player.

VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date help needed

2004-06-25 Thread Neil Smith [MVP, Digital media]
No, it's actually very easy to do the autocomplete once you get the hang of 
it. Actually the way I've done it is to populate a multi-select box but you 
could also use a DIV and write out the values

Dump the email addresses as an XML file (generate this dynamically) then 
use XSLT to read out matching rows on each keyup ... basically you filter 
the XML file each time till you get down to one value

Yes, it's javascript but it works really well as long as you have some 
control over your client browser (in the case of your boss, probably IE but 
it can be made to work in mozilla / firefox too)

Mail me offlist if you want a working example.
Cheers - Neil
At 11:07 25/06/2004 +, you wrote:
Message-Id: <[EMAIL PROTECTED]>
From: "Chris Payne" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Date: Thu, 24 Jun 2004 22:53:13 -0400
MIME-Version: 1.0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Subject: RE: [PHP-DB] Date help needed
One thing he wanted which I didn't know how to do (Javascript I guess which
I don't know much about) was to preload a database of email address, and as
he started to type an email address it would do a sort of auto-complete, but
have no clue how to go about that so just told him not viable ATM.


CaptionKit http://www.captionkit.com : Production tools
for accessible subtitled internet media, transcripts
and searchable video. Supports Real Player, Quicktime
and Windows Media Player.
VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] Date Select

2004-06-25 Thread Tom Chubb
Jeffrey,
Thanks for this,
I've just realised that it's always the same no of inserts, so perhaps I
should just order by date then my previous sort field and then limit the
result to 20?
(It's all 20 results that I need displayed)
Thanks,
Tom


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 25 June 2004 12:15
To: Tom Chubb
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Date Select





>How can I query a MySQL table to get the latest results from a date field?
>Basically, I am inserting several records at a time at the end of each
week.
>I want to have a page that displays the results for the last week only.
>The date format in the field is -MM-DD


if you want the latest row -
  select * from table order by max(date_column) limit 1;

if you want rows in a range of dates there are lots o ways, and instead of
showing one or two, I'd suggest taking a look at the manual on dates
http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html, and seeing
what fits your needs best.  Seems like you may want to look at BETWEEN

And if you don't want to use those, you are always free to use
  select * from table where date_column < '-mm-dd' and date_column
< '-mm-dd' order by date_col desc

HTH
Jeff

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date Select

2004-06-25 Thread jeffrey_n_Dyke



>How can I query a MySQL table to get the latest results from a date field?
>Basically, I am inserting several records at a time at the end of each
week.
>I want to have a page that displays the results for the last week only.
>The date format in the field is -MM-DD


if you want the latest row -
  select * from table order by max(date_column) limit 1;

if you want rows in a range of dates there are lots o ways, and instead of
showing one or two, I'd suggest taking a look at the manual on dates
http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html, and seeing
what fits your needs best.  Seems like you may want to look at BETWEEN

And if you don't want to use those, you are always free to use
  select * from table where date_column < '-mm-dd' and date_column
< '-mm-dd' order by date_col desc

HTH
Jeff

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Date help needed

2004-06-24 Thread Chris Payne
Hi there,

>A drop down with 365 days !?!?   Isn't that a "little" big?

Actually it's Fridays, Sundays and Tuesdays for 2 years (365 was an example)
it's for an Admin for a client, and he asked that it be in a dropdown box
and he's the boss, so he gets what he wants :-)

One thing he wanted which I didn't know how to do (Javascript I guess which
I don't know much about) was to preload a database of email address, and as
he started to type an email address it would do a sort of auto-complete, but
have no clue how to go about that so just told him not viable ATM.

Chris

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date help needed

2004-06-24 Thread Daniel Clark
A drop down with 365 days !?!?   Isn't that a "little" big?

> I have a problem, I currently have some code which populates a dropdown
> box
> - this code gives me every day for the next x amount of days (EG: a years
> worth of days), however what I really need to be able to do, is to find a
> way to display this data in the dropdown box but ONLY show 3 days a week,
> IE: Mondays, Fridays and Sundays, so it would show the dates for each
> Monday, Friday and Sunday for X amount of days (IE: 365 days in the
> dropdown).
>
>
>
> Does anyone have any idea how to do this?  I would really appreciate any
> help, I'd send my sample code only I'm not at my home/work computer ATM.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Date help needed

2004-06-24 Thread Chris Payne
Hi there,

Just got back and tried it and it works perfectly, thank you so much for
your help, you've got me out of a bind here ;-)

Chris

You could loop through the weeks and put those 3 specifically in:
$days = array();
for($i = 0; $i < 365; $i +=7) {
  $days[] = strtotime('next Monday', strtotime('+ '.$i.' days'));
  $days[] = strtotime('next Friday', strtotime('+ '.$i.' days'));
  $days[] = strtotime('next Sunday', strtotime('+ '.$i.' days'));
}

sort($days);

foreach($days as $day) {
  echo date('Y-m-d', $day).'';
}

(This is not tested, but it *should* work,)

On Thu, 24 Jun 2004 17:07:12 -0400, Chris Payne
<[EMAIL PROTECTED]> wrote:
> 
> Hi there everyone,
> 
> I have a problem, I currently have some code which populates a dropdown
box
> - this code gives me every day for the next x amount of days (EG: a years
> worth of days), however what I really need to be able to do, is to find a
> way to display this data in the dropdown box but ONLY show 3 days a week,
> IE: Mondays, Fridays and Sundays, so it would show the dates for each
> Monday, Friday and Sunday for X amount of days (IE: 365 days in the
> dropdown).
> 
> Does anyone have any idea how to do this?  I would really appreciate any
> help, I'd send my sample code only I'm not at my home/work computer ATM.
> 
> Chris
> 
> !DSPAM:40db40cb34094233914063!
> 


-- 
paperCrane --Justin Patrin--

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date help needed

2004-06-24 Thread Justin Patrin
You could loop through the weeks and put those 3 specifically in:
$days = array();
for($i = 0; $i < 365; $i +=7) {
  $days[] = strtotime('next Monday', strtotime('+ '.$i.' days'));
  $days[] = strtotime('next Friday', strtotime('+ '.$i.' days'));
  $days[] = strtotime('next Sunday', strtotime('+ '.$i.' days'));
}

sort($days);

foreach($days as $day) {
  echo date('Y-m-d', $day).'';
}

(This is not tested, but it *should* work,)

On Thu, 24 Jun 2004 17:07:12 -0400, Chris Payne
<[EMAIL PROTECTED]> wrote:
> 
> Hi there everyone,
> 
> I have a problem, I currently have some code which populates a dropdown box
> - this code gives me every day for the next x amount of days (EG: a years
> worth of days), however what I really need to be able to do, is to find a
> way to display this data in the dropdown box but ONLY show 3 days a week,
> IE: Mondays, Fridays and Sundays, so it would show the dates for each
> Monday, Friday and Sunday for X amount of days (IE: 365 days in the
> dropdown).
> 
> Does anyone have any idea how to do this?  I would really appreciate any
> help, I'd send my sample code only I'm not at my home/work computer ATM.
> 
> Chris
> 
> !DSPAM:40db40cb34094233914063!
> 


-- 
paperCrane --Justin Patrin--

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date and time problem

2004-05-15 Thread Bruno Ferreira
Kim Jacobs - MWEB wrote:
I have a script which pulls a date(date default NULL) and a time (time default NULL) 
from a MySQL database, now I would like to display that date and time in a 'pretty' 
format.
I've been able to show the date nicely with the help of this:
$ntime=strtotime($row['date'] $row['time']);
$ndate=date('D d F Y H:i',$ntime);
This shows the date in a 'nice' format (2004-05-10 20:40:00 is shown as Mon 10 May 
2004 00:00), however, it shows the time as 00:00 for all of the games no matter what 
the time is. How do I get it to show the date as 20:40 or 20h40 or 8:40 PM?
If I change the lines to this:
$ntime=strtotime("$row[date] $row[time] GMT");
$ndate=date('D d F Y H:i',$ntime);
the only difference is that it now shows Mon 10 May 2004 02:00 (probably because we 
are 2 hours ahead of GMT)
Any ideas please?
Thanks
K
   

   Well, a solution could easily be arranged to use both fields, but 
really, the best thing to do is to just use a DATETIME field in MySQL 
instead of using both DATE and TIME fields. That will save you a lot of 
headaches now and in the future.

Bruno Ferreira
---
[This E-mail scanned for viruses by Declude Virus]
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Date SELECT with IF

2004-04-15 Thread Marcjon Louwersheimer
try the WHERE clause.
SELECT name, address, phone, date FROM usertable WHERE date =
'-00-00'
And please, look at the mysql documentation, or at least the tutorial.
-- 
  Marcjon

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date SELECT with IF

2004-04-15 Thread Ignatius Reilly
SELECT
IF( B.Booking_End_Date != "-00-00",
DATE_FORMAT( B.Booking_End_Date, "%Y-%m-%d" ),
"N/A"
) AS Booking_End_Date
FROM Bookings AS B, etc.

HTH
Ignatius
_
- Original Message -
From: "Shaun" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 15, 2004 7:44 PM
Subject: [PHP-DB] Date SELECT with IF


> Hi,
>
> Is it possible to have a clause in a mysql SELECT statement? I would the
> query to display the date except where it equals the default 000-00-00 to
> display n/a or something similar.
>
> For example SELECT DATE_FORMAT(B.Booking_End_Date, \"%Y-%m-%d\") AS
'Booking
> End Date' FROM Bookings (IF Booking_End_Date = '-00-00' DISPLAY
'n/a');
>
> I hope this illustrates what I am trying to achieve!
>
> Thanks for your help
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date Manipulation

2004-03-21 Thread John W. Holmes
Shannon Doyle wrote:

My question, how do I get the date entered into the form add 35days to it
and then include that into the same sql query as the first one. Or do I have
to use a second sql query? If the second query how would I get the date and
add 35days??
INSERT INTO table (date1, date2) VALUES (20040321, 20040321 + INTERVAL 
35 DAY)

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] date problem in MySQL DB

2004-01-13 Thread Justin Patrin
Brett King wrote:

Hi Angelo

Yes you will have to reformat and he is something that may help you.
Hope it does
	function dateCheckMysql ($date) {

list($dateDay, $dateMonth, $dateYear) = explode("/", $date);
if ((is_numeric($dateDay)) && (is_numeric($dateMonth)) &&
(is_numeric($dateYear))) {
if (!checkdate($dateMonth, $dateDay, $dateYear)) {
return false;
} else {
return($dateYear."/".$dateMonth."/".$dateDay);
}
} else {
return false;
}
}
	function dateCheckForm($date) {

		list($dateYear, $dateMonth, $dateDay) = explode("-", $date);

if ((is_numeric($dateDay)) && (is_numeric($dateMonth)) &&
(is_numeric($dateYear))) {
return($dateDay."/".$dateMonth."/".$dateYear);
} else {
return false;
}
}
Many Thanks
Brett
Wow, that's lots of code. I'd recommend something simpler. Like:

$mysqlDate = date('Y-m-d', strtotime($myDate));

$myDate = date('m/d/Y', strtotime($mysqlDate));

No checking involved, just one line of code.

--
paperCrane 
--
Question Everything, Reject Nothing
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] date problem in MySQL DB

2004-01-13 Thread brett king


Hi Angelo

Yes you will have to reformat and he is something that may help you.
Hope it does

function dateCheckMysql ($date) {

list($dateDay, $dateMonth, $dateYear) = explode("/", $date);
if ((is_numeric($dateDay)) && (is_numeric($dateMonth)) &&
(is_numeric($dateYear))) {

if (!checkdate($dateMonth, $dateDay, $dateYear)) {
return false;
} else {

return($dateYear."/".$dateMonth."/".$dateDay);
}
} else {

return false;
}
}

function dateCheckForm($date) {

list($dateYear, $dateMonth, $dateDay) = explode("-", $date);

if ((is_numeric($dateDay)) && (is_numeric($dateMonth)) &&
(is_numeric($dateYear))) {

return($dateDay."/".$dateMonth."/".$dateYear);
} else {
return false;
}
}

Many Thanks
Brett

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date problem in MySQL DB

2004-01-13 Thread CPT John W. Holmes
From: "Angelo Zanetti" <[EMAIL PROTECTED]>

> This might be slightly off topic but hopefully someone can help.
> I have a field that is a varchar and I stored dates in it. But now I want
to
> change the type of the column to date, but I have a problem that the
formats
> differ:
>
> my format: mm/dd/
> mySQL format: -mm-dd
>
> So can I either:
> a. change the format of the date format
>
> or
>
> b. do i have to write a function that changes my format to the mySQL
before
> changing the column type??

You need to do option (b). Since this is a PHP list, I'd recommend
strtotime() and date() to do the formatting.

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date function

2003-11-02 Thread Martin Marques
1) Why do you send this to a DB list?
2) Try seeing the Date class of PEAR (PEAR::Date).

El Dom 02 Nov 2003 19:13, OpenSource escribió:
> Hi guys,
> 
> This might not be the best place for this but here goes.
> 
> I want to create a dropdown list with a date range of
> --
> 
>  Today
>  Yesterday
>  Fri 10/31
>  Thu 10/30
>  Wed 10/29
>  Tue 10/28
>  Mon 10/27
>  Sun 10/26
>  Sat 10/25
>  Fri 10/24
>  Thu 10/23
>  Wed 10/22
>  Tue 10/21
>  Mon 10/20
>  Sun 10/19
>  Sun 10/12
>  Sun 10/5
>  Sun 9/28
>  Sun 9/21
>  Sun 9/14
>  Sun 8/31
>  Fri 8/1
>  Wed 7/2
>  Mon 6/2
>  Sat 5/3
>  Thu 4/3
>  Tue 3/4
>  Sun 2/2
>  Fri 1/3
>  Wed 12/4
> 
> --
> I would like to know i can go about doing that. some examples, or if anyone 
has a function already the i could use.
> 
> 
> Thanks in advance,
> 
> 

-- 
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
-
Martín Marqués  |[EMAIL PROTECTED]
Programador, Administrador, DBA |   Centro de Telemática
   Universidad Nacional
del Litoral
-

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date function

2003-11-02 Thread Ignatius Reilly
have a look at the PEAR date package.
http://pear.php.net/package/Date

_
- Original Message -
From: "OpenSource" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, November 02, 2003 11:13 PM
Subject: [PHP-DB] date function


Hi guys,

This might not be the best place for this but here goes.

I want to create a dropdown list with a date range of
--

 Today
 Yesterday
 Fri 10/31
 Thu 10/30
 Wed 10/29
 Tue 10/28
 Mon 10/27
 Sun 10/26
 Sat 10/25
 Fri 10/24
 Thu 10/23
 Wed 10/22
 Tue 10/21
 Mon 10/20
 Sun 10/19
 Sun 10/12
 Sun 10/5
 Sun 9/28
 Sun 9/21
 Sun 9/14
 Sun 8/31
 Fri 8/1
 Wed 7/2
 Mon 6/2
 Sat 5/3
 Thu 4/3
 Tue 3/4
 Sun 2/2
 Fri 1/3
 Wed 12/4

--
I would like to know i can go about doing that. some examples, or if anyone
has a function already the i could use.


Thanks in advance,

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date function

2003-11-02 Thread Larry E . Ullman
This might not be the best place for this but here goes.
You are correct. At the very least, you should probably be using the 
general PHP list, not the database one.

I want to create a dropdown list with a date range of
Not to be obstinate, but it looks like you already have. But, assuming 
that you mean that you want to create this dynamically in PHP starting 
with today's date, then you need to establish some guidelines or rules 
for what dates make up the list. I can't really see a pattern in your 
list (every day for two weeks, then every week for five weeks, then two 
weeks once, then monthly going back a year) so I can't offer specifics. 
The answer will probably be found using a for loop and the date 
function.

Larry

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] date function

2003-09-05 Thread Jason Wong
On Saturday 06 September 2003 06:01, Darryl wrote:

> I have some php code that pulls from the mysql database.  Here it is:
>
>   mysql_connect("wildcat.osborneindustries.com", "webuser",
> "webpass");
>$mymonth = date('n');
>$cyear = date('Y');
>  $query = "SELECT name,hdate FROM emp2 where month(hdate)=$mymonth
> order by hdate";
>  $result = mysql_db_query("iweb", $query);
>
>  if ($result) {
>echo "";
>while ($r = mysql_fetch_array($result)) {
>   $name = $r["name"];
>  $hyear = date('Y',$r["hdate"]);
>  $timein = $cyear - $hyear;
>  if ($timein > 0) {
> echo
> "$name$timein$cyear$hyear";}
>}
>echo "";
>  } else {
> echo "No data.";
> }
> mysql_free_result($result); ?>
>
> I'm trying to figure out years of employment based on hiredate.  Its not
> working as expected.  $timein is always
> 1969.  Date in the database is -MM-DD.  What have I screwed up ?

date() in php expects a unix timestamp. Dates in MySQL are NOT stored in unix 
timestamp format.

You can perform the calculations directly in MySQL

mysql manual > Tutorial Introduction > Date Calculations


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
People with narrow minds usually have broad tongues.
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Date format problem

2003-08-14 Thread Jennifer Goodie
> 
> I have a field in my mysql db wich is a timestamp with the format
> 
> mmddhhmmss
> 
> and I would like to display it like:
> 
> dd/mm/
> 
http://www.mysql.com/doc/en/Date_and_time_functions.html#IDX1333

SELECT DATE_FORMAT(timestamp_col_name, '%d/%m/%Y') FROM table_name

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Date problem

2003-07-14 Thread Gary . Every

> // Do some number crunching here //
> 
> $newnow = $now-$numweeks;
> 
> echo $now;
> 
> $converted_date = date("d-m-y",$now);
> 
> echo "$converted_date";



You should be running your $convewrted_date on $newnow, not $now




Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
"Pay It Forward"
mailto:[EMAIL PROTECTED]
http://accessingram.com


> -Original Message-
> From: Chris Payne [mailto:[EMAIL PROTECTED]
> Sent: Monday, July 14, 2003 3:45 AM
> To: php
> Subject: [PHP-DB] Date problem
> 
> 
> Hi there everyone,
> 
> I use the below code to grab the current date, convert it to 
> a unix timestamp to do some bits then it's supposed to change 
> the date back with the new values (IE: current date - x 
> amount of seconds) but it's not doing it correctly, it's 
> probably DEAD obvious to everyone as my brain has probably 
> fried :-)  But here's the code, when I convert it back to 
> d,m,Y it says it's 2004 which it shouldn't.
> 
> Thanks
> 
> Chris
> 
> ---
> 
> $secsinweek = 604800;
> 
> $numweeks = $secsinweek * 7;
> 
> $curdate = date("d-m-Y");
> 
> // Split the strings into day, month, year
> list($cd, $cm, $cy) = split("-", $curdate);
> 
> // Create unix time stamps for the start and end date
>  $now = mktime(0,0,0,$cd,$cm,$cy);
> 
> // Do some number crunching here //
> 
> $newnow = $now-$numweeks;
> 
> echo $now;
> 
> $converted_date = date("d-m-y",$now);
> 
> echo "$converted_date";
> 


Re: [PHP-DB] date, and time?

2003-07-10 Thread jeffrey_n_Dyke

you could change mysql to a few different date formats, but i don't _think_
that is one of them.

Why not just take care of a format change on the way out with DATE_FORMAT.
Also, if you store the date as one of the defualt date[time] values then
you have tons of functions that you can run against your data...

http://www.mysql.com/doc/en/Date_and_time_types.html
http://www.mysql.com/doc/en/Date_and_time_functions.html

hth
jeff


   

  [EMAIL PROTECTED]
 
  sungard.com To:   [EMAIL PROTECTED]  
 
  cc:  

  07/10/2003 11:02 AM Subject:  [PHP-DB] date, and time?   

   

   





Cheers for the help on my last auto inc prob..
I checked out phpmyadmin, and I'm loving it...! cheers all

Anyway,
I want to know how to store a date like this in a MySQL database:

date("F j, Y, g:i a");

Resulting in:

July 10, 2003, 3:39 am

But what do I need to set my database table to, to capture the full data.
I can use text, but then I can't sort by date later on

Ideas?

Cheers list...

*
The information contained in this e-mail message is intended only for
the personal and confidential use of the recipient(s) named above.
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is
strictly prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original message.
***







-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date Formatting in PHP

2003-06-10 Thread David Shugarts


This worked perfectly, is very simple for me to use, and I would never have
come upon it in 10,000 years of trying. Thanks!

Thanks also to everyone who offered ideas.

> $f_date = date('F d, Y',strtotime($db_date));


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date Formatting in PHP

2003-06-10 Thread CPT John W. Holmes
> I have a simple need to reformat a variable coming in as $DatePick,
brought
> forward from a MySQL select in the format:
>
> 2003-11-18
>
> I need to convert it to the format
>
> November 18, 2003

$f_date = date('F d, Y',strtotime($db_date));

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date Formatting in PHP

2003-06-10 Thread John R Wunderly
At 05:23 PM 6/10/2003 -0400, David Shugarts wrote:


I have a simple need to reformat a variable coming in as $DatePick, brought
forward from a MySQL select in the format:
2003-11-18

I need to convert it to the format

November 18, 2003
try the "dice-n-slice" method.  use substr and concatenation to build 
$DayReport from the current value of $DatePick.

I am trying to avoid having to mess with the MySQL select statement, as the
output is being passed through several documents. So I need to do it within
PHP.
I tried making a conversion like

$DayReport = date ("F d, Y", $DatePick);

But the value of $DayReport is neither correct nor does it change when
$DatePick changes. For instance, in this example, the $DatePick value of
"2003-11-18" gets converted to "December 31, 1969."
TIA

Dave Shugarts



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Date Formatting in PHP

2003-06-10 Thread Frank Keessen
Hi David,

Try this one:



Regards,

Frank
- Original Message - 
From: "David Shugarts" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 10, 2003 11:23 PM
Subject: [PHP-DB] Date Formatting in PHP


>
>
>
> I have a simple need to reformat a variable coming in as $DatePick,
brought
> forward from a MySQL select in the format:
>
> 2003-11-18
>
> I need to convert it to the format
>
> November 18, 2003
>
> I am trying to avoid having to mess with the MySQL select statement, as
the
> output is being passed through several documents. So I need to do it
within
> PHP.
>
> I tried making a conversion like
>
> $DayReport = date ("F d, Y", $DatePick);
>
> But the value of $DayReport is neither correct nor does it change when
> $DatePick changes. For instance, in this example, the $DatePick value of
> "2003-11-18" gets converted to "December 31, 1969."
>
> TIA
>
> Dave Shugarts
>
>
>
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] date to Y-M-D

2003-03-25 Thread Snijders, Mark
ehmmm what kind of dates do you use, maybe dates of birth?

when using date of unix timestamp you can't have dates befor 1970  so if
those timestamps represents an older date you can't use timestamps!

-mark-


-Oorspronkelijk bericht-
Van: David Rice [mailto:[EMAIL PROTECTED]
Verzonden: Tuesday, March 25, 2003 3:42 PM
Aan: [EMAIL PROTECTED]
Onderwerp: [PHP-DB] date to Y-M-D


a function to convert any date to ymd...


function datetoymd($date){
$dateymd = date('Y-m-d',$date);

return $dateymd;
}

this function when output gives me the date 1970-01-01 (date of the unix 
timestamp start) so, ehm, why!?

cheers,
dave





_
Stay in touch with absent friends - get MSN Messenger 
http://messenger.msn.co.uk


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date to Y-M-D

2003-03-25 Thread CPT John W. Holmes
> function datetoymd($date){
> $dateymd = date('Y-m-d',$date);
>
> return $dateymd;
> }
>
> this function when output gives me the date 1970-01-01 (date of the unix
> timestamp start) so, ehm, why!?

Because you're not passing a valid Unix timestamp or whatever your passing
is empty.

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Date in a dropbox box

2003-03-10 Thread Chris Payne
Hi there,

Thank you John, you are a lifesaver :-)

Chris

> > I have a form which displays 3 dropdowns, day, month and year, I have
> it
> > displaying the default of the dropdown for month no problem, but how
> can I
> > get it to select the current date (day) in the dropdown, but show 31
> days
> > nomatter how many days are in the month?  This is important even
> though it
> > sounds odd :-)
> > 
> > so if it was the 5th of a month, it would show 5 as a default value,
> but
> > allow you to select 1-4 before that and 6-31 after it.
> 
> Lots of ways you can do it.
> 
> $today = date('d');
> for($x=1;$x<=31;$x++)
> {
> echo ' '>$x';
> }
> 
> ---John W. Holmes...
> 
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Date in a dropbox box

2003-03-10 Thread John W. Holmes
> I have a form which displays 3 dropdowns, day, month and year, I have
it
> displaying the default of the dropdown for month no problem, but how
can I
> get it to select the current date (day) in the dropdown, but show 31
days
> nomatter how many days are in the month?  This is important even
though it
> sounds odd :-)
> 
> so if it was the 5th of a month, it would show 5 as a default value,
but
> allow you to select 1-4 before that and 6-31 after it.

Lots of ways you can do it.

$today = date('d');
for($x=1;$x<=31;$x++)
{
echo '$x';
}

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] date functions (generates parse error)

2003-03-05 Thread John W. Holmes
This is very weird. What are you using to create this code?

If you remove all of the spaces (?) before $query, the code doesn't give
a parse error. It shouldn't give one either way, though, if those are
spaces or a tab before your $query = ... line. 

Even if you remove all of the text and only leave , and those
"spaces", PHP will spit something like:

Notice: Use of undefined constant   - assumed ' ' in
c:\inetpub\wwwroot\test.php on line 3

So, the fix is to remove those characters and replace them with spaces
or tabs. 

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/

> -Original Message-
> From: David Rice [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 05, 2003 12:34 PM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] date functions (generates parse error)
> 
> 
> Sorry, I forgot to add the part at the bottom where I am calling the
> function
> 
> =
> 
>  function tips($weekstart){
> 
>   $start = date('Ymd',strtotime($weekstart));
> 
>   $query = "SELECT * FROM Rota WHERE date >= $start and date <=
> ($start +
> INTERVAL 6 DAY) ORDER BY staffid";
>   $result = mysql_query($query);
>   while ($row = mysql_fetch_array($result)){
> 
>   if ( isset ( $tips ) ){
> 
>   if (isset ( $tips[$row[staffid]] ) ){
> 
>   $hours = $row[finish] - $row[start];
>   $tips[$row[staffid]] =
$tips[$row[staffid]] +
> $hours;
> 
>   }
> 
>   else{
> 
>   $tips[$row[staffid]] = $row[finish] -
$row[start];
> 
>   }
>   }
> 
>   else{
> 
>   $tips = array('$row[staffid]' =>( $row[finish] -
> $row[start] ) );
> 
>   }
> 
>   }
> 
>   return $tips;
> 
> }
> 
> function dbconnect(){
>   mysql_connect("localhost", "filterseveuk", "godisadj");
>   mysql_select_db("filterseveuk");
> }
> 
> dbconnect();
> $date = "2003-03-02";
> 
> var_dump(tips($date));
> ?>
> 
> _
> Express yourself with cool emoticons http://messenger.msn.co.uk
> 
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date functions (generates parse error)

2003-03-05 Thread David Rice
Sorry, I forgot to add the part at the bottom where I am calling the 
function

=


	$start = date('Ymd',strtotime($weekstart));

 	$query = "SELECT * FROM Rota WHERE date >= $start and date <= ($start + 
INTERVAL 6 DAY) ORDER BY staffid";
	$result = mysql_query($query);
	while ($row = mysql_fetch_array($result)){

		if ( isset ( $tips ) ){

			if (isset ( $tips[$row[staffid]] ) ){

$hours = $row[finish] - $row[start];
$tips[$row[staffid]] = $tips[$row[staffid]] + $hours;
			}

			else{

$tips[$row[staffid]] = $row[finish] - $row[start];

}
}
		else{

			$tips = array('$row[staffid]' =>( $row[finish] - $row[start] ) );

		}

	}

	return $tips;

}

function dbconnect(){
mysql_connect("localhost", "filterseveuk", "godisadj");
mysql_select_db("filterseveuk");
}
dbconnect();
$date = "2003-03-02";
var_dump(tips($date));
?>
_
Express yourself with cool emoticons http://messenger.msn.co.uk
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] date functions (generates parse error)

2003-03-04 Thread 1LT John W. Holmes
> Here is the whole code of my function
>
> Whenever i run it, it say's there is a parse error on line 6, can't see
what
> is the problem
> the format of $weekstart (as it is stored in the Database) is -MM-DD
>
> =
>  function tips($weekstart){
>
> $start = date('Ymd',strtotime($weekstart));
>
> $query = "SELECT * FROM Rota WHERE date >= $start and date <= ($start +
> INTERVAL 6 DAY) ORDER BY staffid";
> $result = mysql_query($query);
> while ($row = mysql_fetch_array($result)){
>
> if ( isset ( $tips ) ){
>
> if (isset ( $tips[$row[staffid]] ) ){
>
> $hours = $row[finish] - $row[start];
> $tips[$row[staffid]] = $tips[$row[staffid]] + $hours;
>
> }
>
> else{
>
> $tips[$row[staffid]] = $row[finish] - $row[start];
>
> }
> }
>
> else{
>
> $tips = array('$row[staffid]' =>( $row[finish] - $row[start] ) );
>
> }
>
> }
>
> return $tips;
>
> }

I cut and pasted your exact code here and didn't get a parse error.

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date functions (generates parse error)

2003-03-04 Thread David Rice
Here is the whole code of my function

Whenever i run it, it say's there is a parse error on line 6, can't see what 
is the problem
the format of $weekstart (as it is stored in the Database) is -MM-DD

=

	$start = date('Ymd',strtotime($weekstart));

 	$query = "SELECT * FROM Rota WHERE date >= $start and date <= ($start + 
INTERVAL 6 DAY) ORDER BY staffid";
	$result = mysql_query($query);
	while ($row = mysql_fetch_array($result)){

		if ( isset ( $tips ) ){

			if (isset ( $tips[$row[staffid]] ) ){

$hours = $row[finish] - $row[start];
$tips[$row[staffid]] = $tips[$row[staffid]] + $hours;
			}

			else{

$tips[$row[staffid]] = $row[finish] - $row[start];

}
}
		else{

			$tips = array('$row[staffid]' =>( $row[finish] - $row[start] ) );

		}

	}

	return $tips;

}

_
Stay in touch with absent friends - get MSN Messenger 
http://messenger.msn.co.uk

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] date functions

2003-03-04 Thread 1LT John W. Holmes
> I want to use it in this function that i am creating (it's for a
resteraunt
> automated tips system, to work out how much tips each staff member is
> entitled to.
>
> 
> function tips($weekstart){
> /* JUST BELOW HERE IS WHERE I NEED TO GET THE DATE OF 6
> DAYS AFTER THE
> SPECIFIED DATE OF THE START OF THE WEEK */
> $weekend = date($weekstart +6);
>
> $query = "SELECT * FROM Rota WHERE date => $weekstart
>  AND date <= $weekend ORDER BY staffid";
>
> etc...

What format is $weekstart in? Maybe you said already, I can't remember.

You could try

$weekend = strtotime($weekstart . ' +6 days');

Since I think your 'date' column is a TIMESTAMP, you'll need to format
$weekstart and $weekend as MMDD in order to get what you have above to
work.

Maybe try this:

function tips($weekstart){
  $start = date('Ymd',strtotime($weekstart));

  $query = "SELECT * FROM Rota WHERE date >= $start and date <= ($start +
INTERVAL 6 DAY) ORDER BY staffid";

  etc...

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] date functions

2003-03-04 Thread Hutchins, Richard
Good stuff here.

http://www.mysql.com/doc/en/Date_and_time_functions.html

Check out the SELECT DATE_ADD section. That might be what you're looking
for.

HTH,
Rich

> -Original Message-
> From: David Rice [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 04, 2003 9:36 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] date functions
> 
> 
> 
> 
> I am looking for a way to take a date stored in a mysql 
> database... and find 
> out the date seven days later.
> 
> how would i do this?!
> 
> 
> cheers, dave
> 
> 
> 
> _
> Chat online in real time with MSN Messenger http://messenger.msn.co.uk
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] date functions

2003-03-04 Thread 1LT John W. Holmes
> I am looking for a way to take a date stored in a mysql database... and
find
> out the date seven days later.
>
> how would i do this?!

too easy...

SELECT date_column + INTERVAL 7 DAY FROM your_table ...

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Date

2003-02-28 Thread Snijders, Mark
go to mysql.com en look for date



-Original Message-
From: Jorge Miguel Fonseca Martins [mailto:[EMAIL PROTECTED]
Sent: vrijdag 28 februari 2003 16:23
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Date


How can a make a query that lists all the fields where a datefield as
the date of tomorow?
 
thanks
 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Date Range Question...

2003-02-04 Thread NIPP, SCOTT V (SBCSI)
WOW...  I have never even heard of BETWEEN before.  How does this
look to you?

SELECT StartDate, StopDate, LocationID FROM phpCalendar_Daily WHERE
CURDATE() BETWEEN StopDate AND StopDate

Would the query work like this?  This would mean I don't even have
to care about the difference of 2 or 3 days?

-Original Message-
From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 04, 2003 10:04 AM
To: NIPP, SCOTT V (SBCSI); [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Date Range Question...


> I am working on an app that needs to post information to a website
> based on date.  The tricky part for me is that the date is a range that
> spans either 2 or 3 days.  I want the web page to dynamically populate
this
> information based on a query.  The query will look something like this:
> mysql("Calendar2","SELECT StartDate, StopDate, LocationID FROM
> phpCalendar_Daily WHERE StartDate=CURDATE() ")
>
> My question is say for example the StartDate is actually Jan. 1.
> The page is accessed on Jan. 2 or Jan. 3...  The  StartDate for the next
> entry is Jan. 4.  How do I write this query to select the proper entry?
In
> doing some research, it appears that a MySQL "SELECT CASE" might do the
> trick, but I have never used this before.  The other option I can envision
> is using PHP to handle the login and simply running the query, testing the
> result, if NULL, run the query again with CURDATE(-1).
> Any hints, ideas, or suggestions would be most appreciated.  Thanks
> in advance.

If I understand you correctly, I think you could use something like this:

SELECT StartDate, StopDate, LocationID FROM phpCalendar_Daily WHERE
StartDate BETWEEN CURDATE() AND CURDATE() - INTERVAL $x DAY

Where $x is 2 or 3, depending on your case.

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Date Range Question...

2003-02-04 Thread 1LT John W. Holmes
> I am working on an app that needs to post information to a website
> based on date.  The tricky part for me is that the date is a range that
> spans either 2 or 3 days.  I want the web page to dynamically populate
this
> information based on a query.  The query will look something like this:
> mysql("Calendar2","SELECT StartDate, StopDate, LocationID FROM
> phpCalendar_Daily WHERE StartDate=CURDATE() ")
>
> My question is say for example the StartDate is actually Jan. 1.
> The page is accessed on Jan. 2 or Jan. 3...  The  StartDate for the next
> entry is Jan. 4.  How do I write this query to select the proper entry?
In
> doing some research, it appears that a MySQL "SELECT CASE" might do the
> trick, but I have never used this before.  The other option I can envision
> is using PHP to handle the login and simply running the query, testing the
> result, if NULL, run the query again with CURDATE(-1).
> Any hints, ideas, or suggestions would be most appreciated.  Thanks
> in advance.

If I understand you correctly, I think you could use something like this:

SELECT StartDate, StopDate, LocationID FROM phpCalendar_Daily WHERE
StartDate BETWEEN CURDATE() AND CURDATE() - INTERVAL $x DAY

Where $x is 2 or 3, depending on your case.

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] date: reverse order

2003-02-04 Thread Addison Ellis
thank you... this worked. best, addison


Simple MySQL.

After your ORDER BY clause use either ASC (I think this is the default) or
DESC. I'm pretty sure this'll work on date fields to produce the results you
want.

Your query will end up looking like:
"...order by createdate DESC"


 -Original Message-
 From: Addison Ellis [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, February 04, 2003 5:28 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] date: reverse order


 hello,
	when retrieving data from the db and displaying it on the
 page by creation date how can i reverse the order so that the most
 recent entry appears first? here's what i have now:

 


 thank you addison
 --
 Addison Ellis
 small independent publishing co.
 114 B 29th Avenue North
 Nashville, TN 37203
 (615) 321-1791
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]
 subsidiaries of small independent publishing co.
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
Addison Ellis
small independent publishing co.
114 B 29th Avenue North
Nashville, TN 37203
(615) 321-1791
[EMAIL PROTECTED]
[EMAIL PROTECTED]
subsidiaries of small independent publishing co.
[EMAIL PROTECTED]
[EMAIL PROTECTED]

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] date: reverse order

2003-02-04 Thread Hutchins, Richard
Simple MySQL.

After your ORDER BY clause use either ASC (I think this is the default) or
DESC. I'm pretty sure this'll work on date fields to produce the results you
want.

Your query will end up looking like:
"...order by createdate DESC"

> -Original Message-
> From: Addison Ellis [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, February 04, 2003 5:28 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] date: reverse order
> 
> 
> hello,
>   when retrieving data from the db and displaying it on the 
> page by creation date how can i reverse the order so that the most 
> recent entry appears first? here's what i have now:
> 
>  require("config.php");
> 
>  $obj = mysql_db_query($dbname,"select * from ads 
> order by createdate");
> ?>
> 
> 
> thank you addison
> -- 
> Addison Ellis
> small independent publishing co.
> 114 B 29th Avenue North
> Nashville, TN 37203
> (615) 321-1791
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> subsidiaries of small independent publishing co.
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] date: reverse order

2003-02-04 Thread 1LT John W. Holmes
> when retrieving data from the db and displaying it on the
> page by creation date how can i reverse the order so that the most
> recent entry appears first? here's what i have now:
>
>  require("config.php");
>
>  $obj = mysql_db_query($dbname,"select * from ads order by
createdate");
> ?>

You rely on the list to much for simple questions.

SELECT * FROM ads ORDER BY createdate DESC

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Date format in MySQL

2003-02-03 Thread Adam Voigt




$query = mysql_query("SELECT UNIX_TIMESTAMP(fieldname) AS date WHERE id = '1';");

$array = mysql_fetch_array($query);



$mydate = date("j F, Y",$array[date]);



Change fieldname and the where clause, and that should work.

If you want to further munipulate how it looks, just look at the

date manual page:



http://www.php.net/date



And change the first parameter to the date function.





On Mon, 2003-02-03 at 09:09, RUBANOWICZ Lisa wrote:

Hi All, I have a date format of -MM-DD in MySQL and am showing it on a PHP page.  However I want to show it as 

"2 February, 2003"

or "2 February"

Can someone please help me.  The date will not necessarily be todays date (I looked at the datetime() function and the getdate() function but couldn't work it out for these)

Thanks for your support

All the best

Lisa



Lisa Rubanowicz

CNH Ireland

Tel: +353 46 77663

Email:   [EMAIL PROTECTED]



 








-- 
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc








signature.asc
Description: This is a digitally signed message part


Re: [PHP-DB] Date format in MySQL

2003-02-03 Thread Jeffrey_N_Dyke

Or if you want to change it when you're pulling out of mysql you can use
the DATE_FORMAT( ) function...

hth
jeff


   
  
John Krewson   
  
  
s.utk.edu>cc: "'[EMAIL PROTECTED]'" 
<[EMAIL PROTECTED]>
              Subject: Re: [PHP-DB] Date format in 
MySQL 
02/03/2003 
  
09:32 AM   
  
   
  
   
  




strftime()

offers a lot of formatting options for dates.

Hope it helps.

RUBANOWICZ Lisa wrote:
> Hi All, I have a date format of -MM-DD in MySQL and am showing it on
a PHP page.  However I want to show it as
> "2 February, 2003"
> or "2 February"
> Can someone please help me.  The date will not necessarily be todays date
(I looked at the datetime() function and the getdate() function but
couldn't work it out for these)
> Thanks for your support
> All the best
> Lisa
>
> Lisa Rubanowicz
> CNH Ireland
> Tel: +353 46 77663
> Email:  <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]
>
>
>
>
>

--
John Krewson
Programmer - SWORPS


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Date format in MySQL

2003-02-03 Thread John Krewson
strftime()

offers a lot of formatting options for dates.

Hope it helps.

RUBANOWICZ Lisa wrote:

Hi All, I have a date format of -MM-DD in MySQL and am showing it on a PHP page.  However I want to show it as 
"2 February, 2003"
or "2 February"
Can someone please help me.  The date will not necessarily be todays date (I looked at the datetime() function and the getdate() function but couldn't work it out for these)
Thanks for your support
All the best
Lisa

Lisa Rubanowicz
CNH Ireland
Tel: +353 46 77663
Email:   [EMAIL PROTECTED]

 

 


--
John Krewson
Programmer - SWORPS


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Date math functions...

2003-01-15 Thread 1LT John W. Holmes
> > > mysql("$DBName","UPDATE Balances SET CompEarned=CompTaken+8 WHERE
> > > said='$said'") or die(mysql_error());
> > > mysql("$DBName","INSERT INTO Log VALUES(DATE_ADD($StopDate,
> > > INTERVAL 1 DAY,'',1,2,'$CalendarDetailsID')") or die(mysql_error());

> Actually this is generating another error.  Now, without the single
> quotes I am getting the following error:
>
> Column 'StartDate' cannot be null
>
> It looks like for some reason the DATE_ADD is returning a NULL
> value.  Any more ideas?

Are you sure $StopDate has a value and is in the right format? Echo out your
query to the screen when you get an error, so you can look for obvious
mistakes.

Is this just example code?  You're using a function called mysql(), which
isn't standard.

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Date math functions...

2003-01-15 Thread Jason Wong
On Thursday 16 January 2003 00:55, NIPP, SCOTT V (SBCSI) wrote:
> Actually this is generating another error.  Now, without the single
> quotes I am getting the following error:
>
>   Column 'StartDate' cannot be null
>
>   It looks like for some reason the DATE_ADD is returning a NULL
> value.  Any more ideas?

Which probably means your $StopDate is 0. What does it actually contain? You 
really should assign your query to some variable ($query) THEN plug it into 
your query function. If and you have any problems you can echo $query to see 
what you're passing to mysql.


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *


/*
I'm having BEAUTIFUL THOUGHTS about the INSIPID WIVES of smug and
wealthy CORPORATE LAWYERS ...
*/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Date math functions...

2003-01-15 Thread NIPP, SCOTT V (SBCSI)
Actually this is generating another error.  Now, without the single
quotes I am getting the following error:

Column 'StartDate' cannot be null

It looks like for some reason the DATE_ADD is returning a NULL
value.  Any more ideas?

-Original Message-
From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 15, 2003 10:32 AM
To: 1LT John W. Holmes; NIPP, SCOTT V (SBCSI); [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Date math functions...


> [snip]
> > if ($dateDiff == 3) {
> > mysql("$DBName","UPDATE Balances SET CompEarned=CompTaken+8 WHERE
> > said='$said'") or die(mysql_error());
> > mysql("$DBName","INSERT INTO Log VALUES('DATE_ADD($StopDate,
> > INTERVAL 1 DAY','',1,2,'$CalendarDetailsID')") or die(mysql_error());
> >
> > My big question is about using the "DATE_ADD" MySQL function inside
> > the INSERT statement.  Is this allowed?  If it is allowed, is it a bad
> idea
> > for some reason?  Is there a better way of doing this?  Thanks in
advance.
>
> Sure, that's allowed. You have $StopDate in PHP, so you could do it with
> some math in PHP, also, but then you'd have to worry about the end of
> months, years, etc, whereas DATE_ADD will do this for you.
>
> ---John Holmes...

Wait... just noticed your syntax error. Don't enclose the function in single
quotes, otherwise you're trying to insert a string.

Should be:

... VALUES (DATE_ADD($StopDate,INTERVAL 1 DAY), ...

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] Date math functions...

2003-01-15 Thread NIPP, SCOTT V (SBCSI)
Thanks.  I was noticing that it was not working.  Let me give this a
try and see how things go.

-Original Message-
From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 15, 2003 10:32 AM
To: 1LT John W. Holmes; NIPP, SCOTT V (SBCSI); [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Date math functions...


> [snip]
> > if ($dateDiff == 3) {
> > mysql("$DBName","UPDATE Balances SET CompEarned=CompTaken+8 WHERE
> > said='$said'") or die(mysql_error());
> > mysql("$DBName","INSERT INTO Log VALUES('DATE_ADD($StopDate,
> > INTERVAL 1 DAY','',1,2,'$CalendarDetailsID')") or die(mysql_error());
> >
> > My big question is about using the "DATE_ADD" MySQL function inside
> > the INSERT statement.  Is this allowed?  If it is allowed, is it a bad
> idea
> > for some reason?  Is there a better way of doing this?  Thanks in
advance.
>
> Sure, that's allowed. You have $StopDate in PHP, so you could do it with
> some math in PHP, also, but then you'd have to worry about the end of
> months, years, etc, whereas DATE_ADD will do this for you.
>
> ---John Holmes...

Wait... just noticed your syntax error. Don't enclose the function in single
quotes, otherwise you're trying to insert a string.

Should be:

... VALUES (DATE_ADD($StopDate,INTERVAL 1 DAY), ...

---John Holmes...

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Date math functions...

2003-01-15 Thread 1LT John W. Holmes
> [snip]
> > if ($dateDiff == 3) {
> > mysql("$DBName","UPDATE Balances SET CompEarned=CompTaken+8 WHERE
> > said='$said'") or die(mysql_error());
> > mysql("$DBName","INSERT INTO Log VALUES('DATE_ADD($StopDate,
> > INTERVAL 1 DAY','',1,2,'$CalendarDetailsID')") or die(mysql_error());
> >
> > My big question is about using the "DATE_ADD" MySQL function inside
> > the INSERT statement.  Is this allowed?  If it is allowed, is it a bad
> idea
> > for some reason?  Is there a better way of doing this?  Thanks in
advance.
>
> Sure, that's allowed. You have $StopDate in PHP, so you could do it with
> some math in PHP, also, but then you'd have to worry about the end of
> months, years, etc, whereas DATE_ADD will do this for you.
>
> ---John Holmes...

Wait... just noticed your syntax error. Don't enclose the function in single
quotes, otherwise you're trying to insert a string.

Should be:

... VALUES (DATE_ADD($StopDate,INTERVAL 1 DAY), ...

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Date math functions...

2003-01-15 Thread 1LT John W. Holmes
[snip]
> if ($dateDiff == 3) {
> mysql("$DBName","UPDATE Balances SET CompEarned=CompTaken+8 WHERE
> said='$said'") or die(mysql_error());
> mysql("$DBName","INSERT INTO Log VALUES('DATE_ADD($StopDate,
> INTERVAL 1 DAY','',1,2,'$CalendarDetailsID')") or die(mysql_error());
>
> My big question is about using the "DATE_ADD" MySQL function inside
> the INSERT statement.  Is this allowed?  If it is allowed, is it a bad
idea
> for some reason?  Is there a better way of doing this?  Thanks in advance.

Sure, that's allowed. You have $StopDate in PHP, so you could do it with
some math in PHP, also, but then you'd have to worry about the end of
months, years, etc, whereas DATE_ADD will do this for you.

---John Holmes...


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] Date Question

2002-11-29 Thread Jason Wong
On Saturday 30 November 2002 12:30, Chris Payne wrote:
> Hi there everyone,
>
> I've never really used the date functions beyond getting it to store the
> current date in a db.
>
> I have a dilema in that I need to get all the days in the current month and
> all the days in the next month (whatever the next month is depends on the
> current month the script was ran)).

Please be more specific. What are you doing with the days that you get? Are 
you putting them into an array? Or did you want to query a database for dates 
that lie within a certain range? If the latter then please say which database 
you're using.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *


/*
Fortune finishes the great quotations, #12

Those who can, do.  Those who can't, write the instructions.
*/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] date()

2002-11-18 Thread Jeffrey_N_Dyke

whooops.  I meant DATE_FORMAT.  Sorry.


   
 
Jeffrey_N_Dyke 
 
@Keane.com   To: "'Edward Peloke'" 
<[EMAIL PROTECTED]>
 cc: "'Php-Db'" <[EMAIL PROTECTED]> 
 
                11/18/2002   Subject: RE: [PHP-DB] date()  
 
02:34 PM   
 
   
 
   
 





you can use the mysql date function and format it as you're pulling it out
of MySql

select date(column_name, %m/%d/%Y) from table;

this will return it formatted like 11/18/2002  or there are other options.

http://www.mysql.com/doc/en/Date_and_time_functions.html

this seems to be whar you're looking for...
hth
jeff



 "Aaron Wolski"
 , "'Php-Db'"
 kbiz.com> <[EMAIL PROTECTED]>
   cc:
 11/18/2002   Subject: RE: [PHP-DB] date()
 02:26 PM






Hmm.. I would get it into a unix_timestamp (unless someone can suggest a
reasoning for now doing so).

Select unix_timestamp(storedDate) as date FROM SomeTable where blah
blah"

Should work like that?

Aaron

-Original Message-----
From: Edward Peloke [mailto:[EMAIL PROTECTED]]
Sent: November 18, 2002 2:50 PM
To: 'Php-Db'
Subject: RE: [PHP-DB] date()

it is just a datetime field and the clients use a javascript calander to
pick the date, here is the exact date as it appears in the db.

2002-11-08 00:00:00

Eddie

-Original Message-
From: Aaron Wolski [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 18, 2002 2:05 PM
To: 'Edward Peloke'; 'Php-Db'
Subject: RE: [PHP-DB] date()


Ok..

I guess it depends on how your date is stored. I always use
unix_timestamps.

If you are too.. then the format I supplied should work as indicated.

Aaron

-----Original Message-
From: Edward Peloke [mailto:[EMAIL PROTECTED]]
Sent: November 18, 2002 2:19 PM
To: 'Php-Db'
Subject: RE: [PHP-DB] date()

When I use this, I get 12/31/69 as my date.

-Original Message-
From: Aaron Wolski [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 13, 2002 4:04 PM
To: 'Edward Peloke'; 'Php-Db'
Subject: RE: [PHP-DB] date()


$date = date("m:d:y", $myrow[datefield]);

Will produce: 11:13:02

http://www.php.net/manual/en/function.date.php


Aaron


-Original Message-
From: Edward Peloke [mailto:[EMAIL PROTECTED]]
Sent: November 13, 2002 4:27 PM
To: Php-Db
Subject: [PHP-DB] date()

I have a date field in my mysql db, when I output the data to the
screen, I
don't want to see the minutes, just the mmddyy.  I can format a date but
can't seem to get it to work passing in the value from
$myrow["datefield"]any ideas?  I don't want to have to worry about
just
pulling what I want in the select clause, I just want to format it when
I
diplay it.

Thanks,
Eddie


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] date()

2002-11-18 Thread Jeffrey_N_Dyke

you can use the mysql date function and format it as you're pulling it out
of MySql

select date(column_name, %m/%d/%Y) from table;

this will return it formatted like 11/18/2002  or there are other options.

http://www.mysql.com/doc/en/Date_and_time_functions.html

this seems to be whar you're looking for...
hth
jeff


   
 
"Aaron Wolski" 
 
, "'Php-Db'"
kbiz.com> <[EMAIL PROTECTED]>   
 
 cc:   
 
                11/18/2002   Subject: RE: [PHP-DB] date()  
 
02:26 PM   
 
   
 
   
 




Hmm.. I would get it into a unix_timestamp (unless someone can suggest a
reasoning for now doing so).

Select unix_timestamp(storedDate) as date FROM SomeTable where blah
blah"

Should work like that?

Aaron

-Original Message-
From: Edward Peloke [mailto:[EMAIL PROTECTED]]
Sent: November 18, 2002 2:50 PM
To: 'Php-Db'
Subject: RE: [PHP-DB] date()

it is just a datetime field and the clients use a javascript calander to
pick the date, here is the exact date as it appears in the db.

2002-11-08 00:00:00

Eddie

-Original Message-
From: Aaron Wolski [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 18, 2002 2:05 PM
To: 'Edward Peloke'; 'Php-Db'
Subject: RE: [PHP-DB] date()


Ok..

I guess it depends on how your date is stored. I always use
unix_timestamps.

If you are too.. then the format I supplied should work as indicated.

Aaron

-Original Message-
From: Edward Peloke [mailto:[EMAIL PROTECTED]]
Sent: November 18, 2002 2:19 PM
To: 'Php-Db'
Subject: RE: [PHP-DB] date()

When I use this, I get 12/31/69 as my date.

-Original Message-
From: Aaron Wolski [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 13, 2002 4:04 PM
To: 'Edward Peloke'; 'Php-Db'
Subject: RE: [PHP-DB] date()


$date = date("m:d:y", $myrow[datefield]);

Will produce: 11:13:02

http://www.php.net/manual/en/function.date.php


Aaron


-Original Message-
From: Edward Peloke [mailto:[EMAIL PROTECTED]]
Sent: November 13, 2002 4:27 PM
To: Php-Db
Subject: [PHP-DB] date()

I have a date field in my mysql db, when I output the data to the
screen, I
don't want to see the minutes, just the mmddyy.  I can format a date but
can't seem to get it to work passing in the value from
$myrow["datefield"]any ideas?  I don't want to have to worry about
just
pulling what I want in the select clause, I just want to format it when
I
diplay it.

Thanks,
Eddie


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] date()

2002-11-18 Thread Jason Wong
On Tuesday 19 November 2002 03:26, Aaron Wolski wrote:
> Hmm.. I would get it into a unix_timestamp (unless someone can suggest a
> reasoning for now doing so).

It really depends on where you want to manipulate the dates. If mostly from 
within  MySQL then store with DATE, DATETIME & TIMESTAMP, if within PHP then 
use UNIX_TIMESTAMP.

> Select unix_timestamp(storedDate) as date FROM SomeTable where blah
> blah"
>
> Should work like that?

Yes, something like that.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *


/*
I didn't order any WOO-WOO ... Maybe a YUBBA ... But no WOO-WOO!
*/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] date()

2002-11-18 Thread Aaron Wolski
Hmm.. I would get it into a unix_timestamp (unless someone can suggest a
reasoning for now doing so).

Select unix_timestamp(storedDate) as date FROM SomeTable where blah
blah" 

Should work like that?

Aaron

-Original Message-
From: Edward Peloke [mailto:[EMAIL PROTECTED]] 
Sent: November 18, 2002 2:50 PM
To: 'Php-Db'
Subject: RE: [PHP-DB] date()

it is just a datetime field and the clients use a javascript calander to
pick the date, here is the exact date as it appears in the db.

2002-11-08 00:00:00

Eddie

-Original Message-
From: Aaron Wolski [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 18, 2002 2:05 PM
To: 'Edward Peloke'; 'Php-Db'
Subject: RE: [PHP-DB] date()


Ok..

I guess it depends on how your date is stored. I always use
unix_timestamps.

If you are too.. then the format I supplied should work as indicated.

Aaron

-Original Message-
From: Edward Peloke [mailto:[EMAIL PROTECTED]]
Sent: November 18, 2002 2:19 PM
To: 'Php-Db'
Subject: RE: [PHP-DB] date()

When I use this, I get 12/31/69 as my date.

-Original Message-
From: Aaron Wolski [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 13, 2002 4:04 PM
To: 'Edward Peloke'; 'Php-Db'
Subject: RE: [PHP-DB] date()


$date = date("m:d:y", $myrow[datefield]);

Will produce: 11:13:02

http://www.php.net/manual/en/function.date.php


Aaron


-Original Message-
From: Edward Peloke [mailto:[EMAIL PROTECTED]]
Sent: November 13, 2002 4:27 PM
To: Php-Db
Subject: [PHP-DB] date()

I have a date field in my mysql db, when I output the data to the
screen, I
don't want to see the minutes, just the mmddyy.  I can format a date but
can't seem to get it to work passing in the value from
$myrow["datefield"]any ideas?  I don't want to have to worry about
just
pulling what I want in the select clause, I just want to format it when
I
diplay it.

Thanks,
Eddie


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] date()

2002-11-18 Thread Edward Peloke
it is just a datetime field and the clients use a javascript calander to
pick the date, here is the exact date as it appears in the db.

2002-11-08 00:00:00

Eddie

-Original Message-
From: Aaron Wolski [mailto:[EMAIL PROTECTED]]
Sent: Monday, November 18, 2002 2:05 PM
To: 'Edward Peloke'; 'Php-Db'
Subject: RE: [PHP-DB] date()


Ok..

I guess it depends on how your date is stored. I always use
unix_timestamps.

If you are too.. then the format I supplied should work as indicated.

Aaron

-Original Message-
From: Edward Peloke [mailto:[EMAIL PROTECTED]]
Sent: November 18, 2002 2:19 PM
To: 'Php-Db'
Subject: RE: [PHP-DB] date()

When I use this, I get 12/31/69 as my date.

-Original Message-
From: Aaron Wolski [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 13, 2002 4:04 PM
To: 'Edward Peloke'; 'Php-Db'
Subject: RE: [PHP-DB] date()


$date = date("m:d:y", $myrow[datefield]);

Will produce: 11:13:02

http://www.php.net/manual/en/function.date.php


Aaron


-Original Message-
From: Edward Peloke [mailto:[EMAIL PROTECTED]]
Sent: November 13, 2002 4:27 PM
To: Php-Db
Subject: [PHP-DB] date()

I have a date field in my mysql db, when I output the data to the
screen, I
don't want to see the minutes, just the mmddyy.  I can format a date but
can't seem to get it to work passing in the value from
$myrow["datefield"]any ideas?  I don't want to have to worry about
just
pulling what I want in the select clause, I just want to format it when
I
diplay it.

Thanks,
Eddie


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




  1   2   >