Avelino Alonso
|
Posted: 10/21/2003, 6:56 AM |
|
Hello:
I have a code beforesow in a record form, width this code:
"
$db1 = new clsDBconvergesrobledo();
$SQL = "SELECT * FROM ordenescarga WHERE delegacion_id=" .
$db1->ToSQL(CCGetSession("delegacion_activa"), ccsInteger) . " AND
ORDENCARGA_ID=" . $db1->ToSQL(CCGetParam("ORDENCARGA_ID"), ccsInteger);
$db1->query($SQL);
$Result = $db1->next_record();
if($Result)
{
$ordenesincificha->FECHA->SetValue($db1->f("FECHA"));
$ordenesincificha->CONDUCTOR_ID->SetValue($db1->f("CONDUCTOR_ID"));
$ordenesincificha->CAMION_ID->SetValue($db1->f("CAMION_ID"));
$ordenesincificha->REMOLQUE_ID->SetValue($db1->f("REMOLQUE_ID"));
$ordenesincificha->CLIENTE_ID->SetValue($db1->f("CLIENTE_ID"));
$ordenesincificha->PROVEEDOR_ID->SetValue($db1->f("PROVEEDOR_ID"));
}
$db1->close();
"
All fields work fine, but the field FECHA post value 01/01/1970 (the
original database date is 2003-10-28), I have tryed width diferents formats
but the result is the same
The control $ordenesincificha->FECHA is a date type, and the database field
FECHA is also a date type.
Any help for this?
Thanks.
Avelino Alonso.
|
|
|
Victor Suarez
|
Posted: 10/31/2003, 8:04 AM |
|
Hi Avelino,
If you don't need the time part, then try declaring a function like this in
your PHP code (it could be changed to consider time):
function DBDateToFieldDate($psDBDate) {
sscanf($psDBDate, "%u-%u-%u %s", $sYear, $sMonth, $sDay, $sTime);
return mktime(0,0,0, $sMonth, $sDay, $sYear);
}
Then, call it before setting the value:
....
$ordenesincificha->FECHA->SetValue(DBDateToFieldDate($db1->f("FECHA")));
....
The field $ordenesincificha->FECHA must be a date field.
Hope it works!
Victor Suarez
vrsuarezd@yahoo.com
"Avelino Alonso" <avelino@big-bros.com> escribió en el mensaje
news:<bn3duk$dgu$1@news.codecharge.com>...
> Hello:
> I have a code beforesow in a record form, width this code:
> "
> $db1 = new clsDBconvergesrobledo();
> $SQL = "SELECT * FROM ordenescarga WHERE delegacion_id=" .
> $db1->ToSQL(CCGetSession("delegacion_activa"), ccsInteger) . " AND
> ORDENCARGA_ID=" . $db1->ToSQL(CCGetParam("ORDENCARGA_ID"), ccsInteger);
> $db1->query($SQL);
> $Result = $db1->next_record();
> if($Result)
> {
> $ordenesincificha->FECHA->SetValue($db1->f("FECHA"));
> $ordenesincificha->CONDUCTOR_ID->SetValue($db1->f("CONDUCTOR_ID"));
> $ordenesincificha->CAMION_ID->SetValue($db1->f("CAMION_ID"));
> $ordenesincificha->REMOLQUE_ID->SetValue($db1->f("REMOLQUE_ID"));
> $ordenesincificha->CLIENTE_ID->SetValue($db1->f("CLIENTE_ID"));
> $ordenesincificha->PROVEEDOR_ID->SetValue($db1->f("PROVEEDOR_ID"));
> }
> $db1->close();
> "
> All fields work fine, but the field FECHA post value 01/01/1970 (the
> original database date is 2003-10-28), I have tryed width diferents
formats
> but the result is the same
> The control $ordenesincificha->FECHA is a date type, and the database
field
> FECHA is also a date type.
>
> Any help for this?
> Thanks.
> Avelino Alonso.
>
>
|
|
|
Avelino Alonso
|
Posted: 10/31/2003, 11:40 PM |
|
Gracias por tu respuesta Victor,
He utilizado una funcion de PHP que de momento funciona correcto.
strtotime($db1->f("FECHA"));
Te escribo en español pues por tu nombre parece que lo entenderás, gracias.
"Victor Suarez" <vsuarez@lalpiz.com> escribió en el mensaje
news:bnu178$ije$1@news.codecharge.com...
> Hi Avelino,
>
> If you don't need the time part, then try declaring a function like this
in
> your PHP code (it could be changed to consider time):
>
> function DBDateToFieldDate($psDBDate) {
> sscanf($psDBDate, "%u-%u-%u %s", $sYear, $sMonth, $sDay, $sTime);
> return mktime(0,0,0, $sMonth, $sDay, $sYear);
> }
>
> Then, call it before setting the value:
>
> ...
> $ordenesincificha->FECHA->SetValue(DBDateToFieldDate($db1->f("FECHA")));
> ...
>
> The field $ordenesincificha->FECHA must be a date field.
>
> Hope it works!
>
> Victor Suarez
>vrsuarezd@yahoo.com
>
>
> "Avelino Alonso" <avelino@big-bros.com> escribió en el mensaje
>news:<bn3duk$dgu$1@news.codecharge.com>...
> > Hello:
> > I have a code beforesow in a record form, width this code:
> > "
> > $db1 = new clsDBconvergesrobledo();
> > $SQL = "SELECT * FROM ordenescarga WHERE delegacion_id=" .
> > $db1->ToSQL(CCGetSession("delegacion_activa"), ccsInteger) . " AND
> > ORDENCARGA_ID=" . $db1->ToSQL(CCGetParam("ORDENCARGA_ID"), ccsInteger);
> > $db1->query($SQL);
> > $Result = $db1->next_record();
> > if($Result)
> > {
> > $ordenesincificha->FECHA->SetValue($db1->f("FECHA"));
> > $ordenesincificha->CONDUCTOR_ID->SetValue($db1->f("CONDUCTOR_ID"));
> > $ordenesincificha->CAMION_ID->SetValue($db1->f("CAMION_ID"));
> > $ordenesincificha->REMOLQUE_ID->SetValue($db1->f("REMOLQUE_ID"));
> > $ordenesincificha->CLIENTE_ID->SetValue($db1->f("CLIENTE_ID"));
> > $ordenesincificha->PROVEEDOR_ID->SetValue($db1->f("PROVEEDOR_ID"));
> > }
> > $db1->close();
> > "
> > All fields work fine, but the field FECHA post value 01/01/1970 (the
> > original database date is 2003-10-28), I have tryed width diferents
> formats
> > but the result is the same
> > The control $ordenesincificha->FECHA is a date type, and the database
> field
> > FECHA is also a date type.
> >
> > Any help for this?
> > Thanks.
> > Avelino Alonso.
> >
> >
>
>
|
|
|
|