pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedDate type: DATE
6+ messages / 6 participants
[nested] [flat]
* Date type: DATE
@ 2003-01-22 18:59 Jesus Rios <galiza-vermelha@wanadoo.es>
2003-01-23 15:10 ` Re: Date type: DATE Adrian Tineo <adriantineo@softhome.net>
2003-01-24 06:05 ` Re: Date type: DATE Mathew Dredge <mathew@idealsoftwaresolutions.com.au>
2003-01-24 12:15 ` Re: Date type: DATE Frank Bax <fbax@sympatico.ca>
0 siblings, 3 replies; 6+ messages in thread
From: Jesus Rios @ 2003-01-22 18:59 UTC (permalink / raw)
To: pgsql-php
Hi everybody.
I've got a form where I ask for the date.I store the date in 3 variables: for
the day i have $day (dd), for the month i have $month (mm) and for the year
$year (yyyy).
At the same time i have a table which is as it follows:
Table "s_objetivos_caso"
Column | Type | Modifiers
-----------------+---------+-----------
dni | integer | not null
fecha | date | not null
cod_s_objetivos | integer | not null
How do i have to insert the column date?.
$date="$year-$month-$day";
insert into s_objetivos_caso values ($dni,$date,$cod_s_objetivos,$conn);
Can anyboy help me for how a i must format the date for introduce into the
table???
Thank you. And sorry with my English.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Date type: DATE
2003-01-22 18:59 Date type: DATE Jesus Rios <galiza-vermelha@wanadoo.es>
@ 2003-01-23 15:10 ` Adrian Tineo <adriantineo@softhome.net>
2 siblings, 0 replies; 6+ messages in thread
From: Adrian Tineo @ 2003-01-23 15:10 UTC (permalink / raw)
To: pgsql-php
> $date="$year-$month-$day";
> insert into s_objetivos_caso values ($dni,$date,$cod_s_objetivos,$conn);
By default, postgresql uses "ISO with US(NonEuropean) conventions" for the
date, wich means mm/dd/yyyy. You can check that with "show datestyle". Of
course, you can change the convention to a European one like dd/mm/yyyy but
I don't know how to make it permanent.... anyway, if we stick to the default
US convention you would do something like:
$date=$month ."/". $day ."/" $year; // Use the dot (.) to join strings
And then do the insert.
Adrian Tineo
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Date type: DATE
2003-01-22 18:59 Date type: DATE Jesus Rios <galiza-vermelha@wanadoo.es>
@ 2003-01-24 06:05 ` Mathew Dredge <mathew@idealsoftwaresolutions.com.au>
2003-01-24 07:26 ` Re: Date type: DATE Alan T. Miller <amiller@hollywood101.com>
2 siblings, 1 reply; 6+ messages in thread
From: Mathew Dredge @ 2003-01-24 06:05 UTC (permalink / raw)
To: Jesus Rios <galiza-vermelha@wanadoo.es>; pgsql-php
Try putting single quotes around the date, this works for me..
insert into s_objetivos_caso values ($dni,'$date',$cod_s_objetivos,$conn);
----- Original Message -----
From: "Jesus Rios" <galiza-vermelha@wanadoo.es>
To: "POSTGRESLQ-PHP" <pgsql-php@postgresql.org>
Sent: Thursday, January 23, 2003 5:59 AM
Subject: [PHP] Date type: DATE
>
> Hi everybody.
>
> I've got a form where I ask for the date.I store the date in 3 variables:
for
> the day i have $day (dd), for the month i have $month (mm) and for the
year
> $year (yyyy).
> At the same time i have a table which is as it follows:
> Table "s_objetivos_caso"
> Column | Type | Modifiers
> -----------------+---------+-----------
> dni | integer | not null
> fecha | date | not null
> cod_s_objetivos | integer | not null
>
> How do i have to insert the column date?.
>
> $date="$year-$month-$day";
> insert into s_objetivos_caso values ($dni,$date,$cod_s_objetivos,$conn);
>
> Can anyboy help me for how a i must format the date for introduce into
the
> table???
>
>
> Thank you. And sorry with my English.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Date type: DATE
2003-01-22 18:59 Date type: DATE Jesus Rios <galiza-vermelha@wanadoo.es>
2003-01-24 06:05 ` Re: Date type: DATE Mathew Dredge <mathew@idealsoftwaresolutions.com.au>
@ 2003-01-24 07:26 ` Alan T. Miller <amiller@hollywood101.com>
2003-01-24 17:03 ` Re: Date type: DATE Keary Suska <hierophant@pcisys.net>
0 siblings, 1 reply; 6+ messages in thread
From: Alan T. Miller @ 2003-01-24 07:26 UTC (permalink / raw)
To: pgsql-php
Please correct me if I am wrong but it looks like you are asking how to
assemble the values in your PHP script into a string that you can insert
into your database... if that is the case you need to use the concatenate
operator in PHP.
You can do this in a few ways...
$date = $year . "-" . $month . "-" . $day;
insert into s_objetivos_caso values ($dni,$date,$cod_s_objetivos,$conn);
or right in the the query itself...
insert into s_objetivos_caso values ($dni,$year . "-" . $month . "-" .
$day,$cod_s_objetivos,$conn);
you would need to check that second way to be sure, but the first one will
work for sure.
Alan
----- Original Message -----
From: "Mathew Dredge" <mathew@idealsoftwaresolutions.com.au>
To: "Jesus Rios" <galiza-vermelha@wanadoo.es>; "POSTGRESLQ-PHP"
<pgsql-php@postgresql.org>
Sent: Thursday, January 23, 2003 10:05 PM
Subject: Re: [PHP] Date type: DATE
> Try putting single quotes around the date, this works for me..
>
> insert into s_objetivos_caso values ($dni,'$date',$cod_s_objetivos,$conn);
>
>
> ----- Original Message -----
> From: "Jesus Rios" <galiza-vermelha@wanadoo.es>
> To: "POSTGRESLQ-PHP" <pgsql-php@postgresql.org>
> Sent: Thursday, January 23, 2003 5:59 AM
> Subject: [PHP] Date type: DATE
>
>
> >
> > Hi everybody.
> >
> > I've got a form where I ask for the date.I store the date in 3
variables:
> for
> > the day i have $day (dd), for the month i have $month (mm) and for the
> year
> > $year (yyyy).
> > At the same time i have a table which is as it follows:
> > Table "s_objetivos_caso"
> > Column | Type | Modifiers
> > -----------------+---------+-----------
> > dni | integer | not null
> > fecha | date | not null
> > cod_s_objetivos | integer | not null
> >
> > How do i have to insert the column date?.
> >
> > $date="$year-$month-$day";
> > insert into s_objetivos_caso values
($dni,$date,$cod_s_objetivos,$conn);
> >
> > Can anyboy help me for how a i must format the date for introduce into
> the
> > table???
> >
> >
> > Thank you. And sorry with my English.
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 3: if posting/reading through Usenet, please send an appropriate
> > subscribe-nomail command to majordomo@postgresql.org so that your
> > message can get through to the mailing list cleanly
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Date type: DATE
2003-01-22 18:59 Date type: DATE Jesus Rios <galiza-vermelha@wanadoo.es>
2003-01-24 06:05 ` Re: Date type: DATE Mathew Dredge <mathew@idealsoftwaresolutions.com.au>
2003-01-24 07:26 ` Re: Date type: DATE Alan T. Miller <amiller@hollywood101.com>
@ 2003-01-24 17:03 ` Keary Suska <hierophant@pcisys.net>
0 siblings, 0 replies; 6+ messages in thread
From: Keary Suska @ 2003-01-24 17:03 UTC (permalink / raw)
To: pgsql-php
on 1/24/03 12:26 AM, amiller@hollywood101.com purportedly said:
> $date = $year . "-" . $month . "-" . $day;
> insert into s_objetivos_caso values ($dni,$date,$cod_s_objetivos,$conn);
>
> or right in the the query itself...
>
> insert into s_objetivos_caso values ($dni,$year . "-" . $month . "-" .
> $day,$cod_s_objetivos,$conn);
>
> you would need to check that second way to be sure, but the first one will
> work for sure.
Neither of these will work, nor any previous suggestion, as date formats are
ambiguous and *must* be quoted:
$date = $year . "-" . $month . "-" . $day;
insert into s_objetivos_caso values ($dni,"'$date'", $cod_s_objetivos,$conn
);
This *will* work, at least as far as the date is concerned.
Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Date type: DATE
2003-01-22 18:59 Date type: DATE Jesus Rios <galiza-vermelha@wanadoo.es>
@ 2003-01-24 12:15 ` Frank Bax <fbax@sympatico.ca>
2 siblings, 0 replies; 6+ messages in thread
From: Frank Bax @ 2003-01-24 12:15 UTC (permalink / raw)
To: Jesus Rios <galiza-vermelha@wanadoo.es>; pgsql-php
At 01:59 PM 1/22/03, Jesus Rios wrote:
>I've got a form where I ask for the date.I store the date in 3 variables: for
>the day i have $day (dd), for the month i have $month (mm) and for the year
>$year (yyyy).
>At the same time i have a table which is as it follows:
> Table "s_objetivos_caso"
> Column | Type | Modifiers
> -----------------+---------+-----------
> dni | integer | not null
> fecha | date | not null
> cod_s_objetivos | integer | not null
>
>How do i have to insert the column date?.
>
> $date="$year-$month-$day";
> insert into s_objetivos_caso values ($dni,$date,$cod_s_objetivos,$conn);
>
>Can anyboy help me for how a i must format the date for introduce into the
>table???
Perhaps you could tell us what goes wrong with the above coding.
Others have mentioned issues with $date variable.
Does the code look "exactly" as above?
Surely you are coding the insert using pg functions?
pg_exec ($conn, "insert into s_objetivos_caso values
($dni,'$date',$cod_s_objetivos)";
Frank
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2003-01-24 17:03 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-01-22 18:59 Date type: DATE Jesus Rios <galiza-vermelha@wanadoo.es>
2003-01-23 15:10 ` Adrian Tineo <adriantineo@softhome.net>
2003-01-24 06:05 ` Mathew Dredge <mathew@idealsoftwaresolutions.com.au>
2003-01-24 07:26 ` Alan T. Miller <amiller@hollywood101.com>
2003-01-24 17:03 ` Keary Suska <hierophant@pcisys.net>
2003-01-24 12:15 ` Frank Bax <fbax@sympatico.ca>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox