![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
28/05/2009, 08:24
|
| | Fecha de Ingreso: febrero-2008
Mensajes: 675
Antigüedad: 17 años Puntos: 5 | |
Respuesta: Saber cuantos años No, este es el codigo que me genera:
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_quedada, $quedada);
$query_Recordset1 = "SELECT PERIOD_DIFF(DATE_FORMAT(NOW(),'%Y%M'), DATE_FORMAT(fecha_naci,'%Y%M') ) FROM usuarios";
$Recordset1 = mysql_query($query_Recordset1, $quedada) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
Y aqui deberia de mostrarlo:
<?php echo $row_Recordset1[' DATE_FORMAT(fecha_naci']; ?>
Pero me salen -47 años cuando deberia de salir 40 años ya que la fecha de nacimiento es el 2/07/1968
Aparte que si pego el codigo, me sale la pagina en blanco, como si fallara algo. Supongo que hay una forma mas sencilla de sacar ese dato.
Un saludo y gracias |