Date Conversion

------=_NextPart_000_0095_01C48534.DBF44970
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi all,

can someone kindly point me to a resource that converts all kinds of =
possible date inputs into MySQL format of YYYY-MM-DD?

example of formats to be converted includes:

d/m/yy
d/m/yyyy
d/mm/yy
d/mm/yyy
dd/mm/yy
dd/mm/yyy
d/mmm/yy
d/mmm/yyyy
dd/mmm/yy
dd/mmm/yyyy

yy - 2 digit representation of year
yyyy - ful numeric representation of year
m - numeric representation of month, without leading zero
mm - numeric representation of month, with leading zero
mmm - short textual representation of month
d - day of month without leading zero
dd - day of month with leadin zero

thanx!

hwee
------=_NextPart_000_0095_01C48534.DBF44970--
Ng Hwee Hwee [ Mi, 18 August 2004 09:05 ] [ ID #265442 ]

Re: Date Conversion

>"Ng Hwee Hwee" <hhwee [at] towa.com.sg> wrote in message
news:009801c484f1$d11c8af0$800101df [at] hweehwee...
>Hi all,
>
>can someone kindly point me to a resource that converts all kinds of
possible date inputs into MySQL format of YYYY-MM-DD?
>
>example of formats to be converted includes:
>
>d/m/yy
>d/m/yyyy
>d/mm/yy
>d/mm/yyy
>dd/mm/yy
>dd/mm/yyy
>d/mmm/yy
>d/mmm/yyyy
>dd/mmm/yy
>dd/mmm/yyyy
>
>yy - 2 digit representation of year
>yyyy - ful numeric representation of year
>m - numeric representation of month, without leading zero
>mm - numeric representation of month, with leading zero
>mmm - short textual representation of month
>d - day of month without leading zero
>dd - day of month with leadin zero
>
>thanx!
>
>hwee

This question belongs more to the general list, but anyway:

You can use strtotime() to convert various formats to a timestamp. Then use
date() to convert it back to your preferred date format:

$timestamp = strtotime($inputDate);
$isoDate = date('Y-m-d', $timestamp);

http://de2.php.net/strtotime
http://de2.php.net/manual/en/function.date.php

Regards, Torsten Roehr

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Torsten Roehr [ Mi, 18 August 2004 10:16 ] [ ID #265444 ]

Check Boxes

can somebody advise me
i want to use checkboxes on my website, i want that if user selects some
checkboxes (there will be more than 20 checkboxes), checkbox's value will be
stored in variables and than SELECT query command will be run using these
variables through PHP. but my problem is that in SELECT query command after
each column name comma (,) is required and if i use the same than it is
displaying "You have an error in your SQL syntax near 'FROM form' at line
1"

pls. help.



balwant

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
balwantsingh [ Mi, 18 August 2004 10:59 ] [ ID #265447 ]

Re: Check Boxes

balwantsingh wrote:
> can somebody advise me
> i want to use checkboxes on my website, i want that if user selects some
> checkboxes (there will be more than 20 checkboxes), checkbox's value will be
> stored in variables and than SELECT query command will be run using these
> variables through PHP. but my problem is that in SELECT query command after
> each column name comma (,) is required and if i use the same than it is
> displaying "You have an error in your SQL syntax near 'FROM form' at line
> 1"

How about showing us some code.... kind of hard to help without that...


--

---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
John Holmes [ Mi, 18 August 2004 14:12 ] [ ID #265448 ]

RE: Check Boxes

i am using following coding


$a1 = $_POST['ch1'];
$a2 = $_POST['ch2'];
$a3 = $_POST['ch3'];

if ($a1 or $a2 or $a3) {
$query = "SELECT $a1, $a2, $a3 FROM form";
$result= [at] mysql_query ($query);
}
Enter_Date<input type="checkbox" name="ch1" value="Enter_Date">
Opening_Units<input type="checkbox" name="ch2" value="Opening_Units">
Unit_Consumed<input type="checkbox" name="ch3" value="Unit_Consumed">


-----Original Message-----
From: John Holmes [mailto:holmes072000 [at] charter.net]
Sent: Wednesday, August 18, 2004 5:43 PM
To: balwantsingh [at] indoasian.com
Cc: php-db [at] lists.php.net
Subject: Re: [PHP-DB] Check Boxes




balwantsingh wrote:
> can somebody advise me
> i want to use checkboxes on my website, i want that if user selects some
> checkboxes (there will be more than 20 checkboxes), checkbox's value will
be
> stored in variables and than SELECT query command will be run using these
> variables through PHP. but my problem is that in SELECT query command
after
> each column name comma (,) is required and if i use the same than it is
> displaying "You have an error in your SQL syntax near 'FROM form' at line
> 1"

How about showing us some code.... kind of hard to help without that...


--

---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
balwantsingh [ Mi, 18 August 2004 11:31 ] [ ID #265449 ]

Re: Check Boxes

If one of the checkboxes is NOT checked, then your query will break as
ift will look something like this:

SELECT xxx,,yyy FROM form;

Name your checkboxes like so: ch[]

<input type=3D"checkbox" name=3D"ch[]" value=3D"Enter_Date"/>

Then you can loop through the checkbox array and run your query that way

$chkboxes =3D $_POST['ch'];
$sql =3D 'SELECT ';
foreach($chkboxes as $k =3D> $v)
{
=09$sql .=3D $v;
=09if($k < (sizeof($chkboxes) - 1))
=09{
=09=09$sql .=3D ', ';
=09}
}
$sql .=3D ' FROM form';


On Wed, 18 Aug 2004 15:01:01 +0530, balwantsingh
<balwantsingh [at] indoasian.com> wrote:
> i am using following coding
>
> $a1 =3D $_POST['ch1'];
> $a2 =3D $_POST['ch2'];
> $a3 =3D $_POST['ch3'];
>
> if ($a1 or $a2 or $a3) {
> $query =3D "SELECT $a1, $a2, $a3 FROM form";
> $result=3D [at] mysql_query ($query);
> }
> Enter_Date<input type=3D"checkbox" name=3D"ch1" value=3D"Enter_Date">
> Opening_Units<input type=3D"checkbox" name=3D"ch2" value=3D"Opening_Units=
">
> Unit_Consumed<input type=3D"checkbox" name=3D"ch3" value=3D"Unit_Consumed=
">
>
>
>
>
> -----Original Message-----
> From: John Holmes [mailto:holmes072000 [at] charter.net]
> Sent: Wednesday, August 18, 2004 5:43 PM
> To: balwantsingh [at] indoasian.com
> Cc: php-db [at] lists.php.net
> Subject: Re: [PHP-DB] Check Boxes
>
> balwantsingh wrote:
> > can somebody advise me
> > i want to use checkboxes on my website, i want that if user selects som=
e
> > checkboxes (there will be more than 20 checkboxes), checkbox's value wi=
ll
> be
> > stored in variables and than SELECT query command will be run using the=
se
> > variables through PHP. but my problem is that in SELECT query command
> after
> > each column name comma (,) is required and if i use the same than it is
> > displaying "You have an error in your SQL syntax near 'FROM form' at l=
ine
> > 1"
>
> How about showing us some code.... kind of hard to help without that...
>
> --
>
> ---John Holmes...
>
> Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
>
> php|architect: The Magazine for PHP Professionals =E2=80=93 www.phparch.c=
om
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
randy sesser [at] gmail.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Randy [ Mi, 18 August 2004 12:24 ] [ ID #265450 ]

Re: Re: Date Conversion

You might want to look into date conversion on the MySQL side:

http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.ht ml

Look for

DATE_FORMAT(date,format)

Paul


On Wed, 18 Aug 2004 10:16:59 +0200, Torsten Roehr <roehr [at] zilleon.com> wrote:
> >"Ng Hwee Hwee" <hhwee [at] towa.com.sg> wrote in message
> news:009801c484f1$d11c8af0$800101df [at] hweehwee...
>
>
> >Hi all,
> >
> >can someone kindly point me to a resource that converts all kinds of
> possible date inputs into MySQL format of YYYY-MM-DD?
> >
> >example of formats to be converted includes:
> >
> >d/m/yy
> >d/m/yyyy
> >d/mm/yy
> >d/mm/yyy
> >dd/mm/yy
> >dd/mm/yyy
> >d/mmm/yy
> >d/mmm/yyyy
> >dd/mmm/yy
> >dd/mmm/yyyy
> >
> >yy - 2 digit representation of year
> >yyyy - ful numeric representation of year
> >m - numeric representation of month, without leading zero
> >mm - numeric representation of month, with leading zero
> >mmm - short textual representation of month
> >d - day of month without leading zero
> >dd - day of month with leadin zero
> >
> >thanx!
> >
> >hwee
>
> This question belongs more to the general list, but anyway:
>
> You can use strtotime() to convert various formats to a timestamp. Then use
> date() to convert it back to your preferred date format:
>
> $timestamp = strtotime($inputDate);
> $isoDate = date('Y-m-d', $timestamp);
>
> http://de2.php.net/strtotime
> http://de2.php.net/manual/en/function.date.php
>
> Regards, Torsten Roehr
>
> --
> 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
Paul [ Mi, 18 August 2004 15:23 ] [ ID #265459 ]

[PHP-GEN] Check Boxes

balwantsingh wrote:
> can somebody advise me
> i want to use checkboxes on my website, i want that if user selects some
> checkboxes (there will be more than 20 checkboxes), checkbox's value will
be
> stored in variables and than SELECT query command will be run using these
> variables through PHP. but my problem is that in SELECT query command
after
> each column name comma (,) is required and if i use the same than it is
> displaying "You have an error in your SQL syntax near 'FROM form' at line
> 1"

i am using following coding

$a1 = $_POST['ch1'];
$a2 = $_POST['ch2'];
$a3 = $_POST['ch3'];

if ($a1 or $a2 or $a3) {
$query = "SELECT $a1, $a2, $a3 FROM form";
$result= [at] mysql_query ($query);
}
Enter_Date<input type="checkbox" name="ch1" value="Enter_Date">
Opening_Units<input type="checkbox" name="ch2" value="Opening_Units">
Unit_Consumed<input type="checkbox" name="ch3" value="Unit_Consumed">



balwant

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
balwantsingh [ Mi, 18 August 2004 11:32 ] [ ID #432018 ]
PHP » gmane.comp.php.database » Date Conversion

Vorheriges Thema: Check Boxes
Nächstes Thema: MySQL denying access to...everything