tengo una pagina asp, en esta pues pregunto por el codigo de una persona determinada y pues investigo cuantos años tienes para ello cuento con un campo llamado fec_nac que es la fecha de nacimiento y pues la logro extraer de la base de datos y uso la funcion datediff para ver los meses que tiene la persona, lo curioso es que si lo hace pero a veces tiene errores por ejemplo, si por ejemplo en la pagina html coloco que nacio el 31 de diciembre del 2004 y esta es la fecha actual "20 de enero del 2005" me dice que tiene 1 mes de nacido y yo quiero que diga que tiene 0 meses como lo arreglo aqui esta el codigo a ver si me pueden hechar una ayudadita
<% option explicit %>
<% if Session("autorizacion")<>1 then
response.redirect "contraseña.asp"
end if%>
<!-- Manual de ASP de WebEstilo.com -->
<html>
<head>
<script language="JavaScript1.1">
var specifyimage=new Array() //Your images
specifyimage[0]="Imagenes/bebe.jpg"
specifyimage[1]="Imagenes/pediatra.jpg"
specifyimage[2]="Imagenes/bebecito.jpg"
var delay=2000 //3 seconds
//Counter for array
var count =1;
var cubeimage=new Array()
for (i=0;i<specifyimage.length;i++){
cubeimage[i]=new Image()
cubeimage[i].src=specifyimage[i]
}
function movecube(){
if (window.createPopup)
cube.filters[0].apply()
document.images.cube.src=cubeimage[count].src;
if (window.createPopup)
cube.filters[0].play()
count++;
if (count==cubeimage.length)
count=0;
setTimeout("movecube()",delay)
}
window.onload=new Function("setTimeout('movecube()',delay)")
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<style type="text/css">
<!--
.Estilo1 {
color: #008000;
font-size: large;
}
.Estilo5 {font-size: small}
.Estilo6 {font-size: 18px}
-->
</style>
<img src="Imagenes/medico.gif" name="cube" width="150" height="120" border=0 style="filter:progid:DXImageTransform.Microsoft.St retch(stretchStyle='PUSH')">
<title>Consulta de Paciente del Programa de Esquema de Vacunacion en el Area de Promocion y Prevencion en Salud Servir S.A</title>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<style type="text/css">
<!--
.Estilo1 {
color: #008000;
font-weight: bold;
}
.Estilo2 {color: #0033FF}
.Estilo4 {color: #0033FF; font-weight: bold; }
.Estilo7 {font-size: 18}
.Estilo8 {font-size: 24px}
.Estilo9 {font-size: 20px}
.Estilo10 {font-size: 21px}
-->
</style>
</head>
<body bgcolor=skyblue>
<div align="right">
<b><font color="#0033FF"> </font></b>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0053)http://www.cicei.com/gsi/tutorial_javascript/cap8.htm -->
<HTML><HEAD>
<TITLE>Aplicaciones práticas</TITLE>
<hr>
<b></b>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<div align="right">
<hr>
<div id="Layer1" style="position:absolute; width:242px; height:20px; z-index:4; left: 538px; top: 16px;"> <b><font color="#0033FF"><%=FormatDateTime(Now, vbLongDate)%></font></b></div>
<b></b>
<br>
</div>
<div id="Layer3" style="position:absolute; width:442px; height:54px; z-index:3; left: 173px; top: 98px;">
<div align="center" class="Estilo1">
<div align="left"><li class="Estilo2 Estilo5">Vacunas que no se han aplicado al Paciente:</li>
<font color="green" face="comic" sans="sans" ms="ms"><br>
<%
response.write session("jaja") %>
<%
response.write session("gato") %>
<%
response.write session("perro") %>
<%
response.write session("chivo") %> </div>
</div>
</div>
<h1><font face= comic sans ms color=green size=5></font><center>
<div id="Layer2" style="position:absolute; width:617px; height:58px; z-index:2; left: 159px; top: 39px; font-size: large;">
<div align="center" class="Estilo6"><span class="Estilo7"><span class="Estilo6"><span class="Estilo8"><span class="Estilo9"><span class="Estilo10"><font color="green" face="comic" sans="sans" ms="ms"><strong>Consulta de Paciente del Programa de Esquema de Vacunacion en el Area de Promocion y Prevencion en Salud</strong></font> <font color="green" face="comic" sans="sans" ms="ms"><strong> Servir S.A</strong><strong></strong></font><font color="green" face="comic" sans="sans" ms="ms"><strong></strong></font></span></span></span></span></span></div>
</div>
</center></h1>
<div align="left">
<%
Dim Conn,SQL, RS,Edad
Dim a,b,f:Date
s=Session("Color")
a=session("jaja")
v=session("codiaja")
Set Conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject ("ADODB.RecordSet")
Conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};Server=127.0.0.1;uid=root;DataBase=datos1"
Conn.Open
SQL="SELECt fec_nac from usuario where codigo='" & v & "' "
Set RS=ConN.Execute(SQL)
f=RS.Fields("fec_nac")
Edad = DateDiff("m",f,date)
cosas=Edad
Conn.Close
set RS = nothing
set Conn = nothing
%>
<span class="Estilo4">Vacunas para la edad:</span><br>
<br>
<%
Dim oConn,strSQL, objRS,i,j,color,s,v,cosas
s=Session("Color")
Set oConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject ("ADODB.RecordSet")
oConn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};Server=127.0.0.1;uid=root;DataBase=datos1"
oConn.Open
strSQL="SELECt * from det_vacuna where vacuna not in(select codi from det1_vacuna det1 where codigo='" & v & "') and tiempo='" & cosas & "'"
Set objRS=OConN.Execute(strSQL)
%>
<CENTER>
</div>
<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=2 text=green>
<TR><TD><span class="Estilo4"> </span> <center class="Estilo4"><b><font face= comic sans ms>Vacunas</font><b></center></TD><TD><span class="Estilo4"> </span> <center class="Estilo4"><b>
<center>
<font face="comic" sans="sans" ms="ms">Numero de Dosis</font>
</center>
</center></TD><TD><span class="Estilo4"> </span> <center class="Estilo4"><b>
<center>
<font face="comic" sans="sans" ms="ms">Estado</font>
</center>
</center> </td></tr>
<%
while (not objRS.Eof)
Response.Write("<tr bgColor=" & color & "><td> " & "<center>" & objRS("nom_vacuna") & "</td><td> <center>" & objRS("num_dosis") & "<center>" & "</td><td> " & "<center>" & "<input name=button type=button onClick=""javascript:Secundaria('ordenvacu.asp?ij= " & objRS("nom_vacuna") & "&ik=" & objRS("num_dosis") & "&il=" & objRS("cod_vacun") & "&im=" & objRS("vacuna") & " ');close();"" value=""Orden de Vacunacion"">" & "</td></tr>")
objRS.MoveNext
wend
oConn.Close
set objRS = nothing
set oConn = nothing
%>
</table>
<br>
<br>
<%
s=Session("Color")
Set oConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject ("ADODB.RecordSet")
oConn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};Server=127.0.0.1;uid=root;DataBase=datos1"
oConn.Open
strSQL="SELECt * from det_vacuna where vacuna not in(select codi from det1_vacuna where codigo='" & v & "') "
Set objRS=OConN.Execute(strSQL)
%>
<CENTER>
</div>
<TABLE BORDER=1 CELLSPACING=2 CELLPADDING=2 text=green>
<TR><TD><span class="Estilo4"> </span> <center class="Estilo4"><b><font face= comic sans ms>Vacunas</font><b></center></TD><TD><span class="Estilo4"> </span> <center class="Estilo4"><b>
<center>
<font face="comic" sans="sans" ms="ms">Numero de Dosis</font>
</center>
</center></TD><TD><span class="Estilo4"> </span> <center class="Estilo4"><b>
<center>
<font face="comic" sans="sans" ms="ms">Estado</font>
</center>
</center> </td></tr>
<%
while (not objRS.Eof)
Response.Write("<tr bgColor=" & color & "><td> " & "<center>" & objRS("nom_vacuna") & "</td><td> <center>" & objRS("num_dosis") & "<center>" & "</td><td> " & "<center>" & "<input name=button type=button onClick=""javascript:ventanaSecundaria('ordenvacu. asp?ij=" & objRS("nom_vacuna") & "&ik=" & objRS("num_dosis") & "&il=" & objRS("cod_vacun") & "&im=" & objRS("vacuna") & " ');close();"" value=""Orden de Vacunacion"">" & "</td></tr>")
objRS.MoveNext
wend
oConn.Close
set objRS = nothing
set oConn = nothing
%>
</table>
<HEAD>
<script language="JavaScript">
function ventanaSecundaria (URL){
window.open(URL,"ventana1","width=500, height=450, scrollbars=no, menubar=no, location=no, resizable=no,toolbar=no")
}
</script>
<script language="JavaScript">
function Secundaria (URL){
window.open(URL,"ventana1","width=500, height=450, scrollbars=no, menubar=no, location=no, resizable=no,toolbar=no")
}
</script>
</HEAD>
<div id="Layer4" style="position:absolute; width:770px; height:18px; z-index:5; left: 6px; top: 160px;">
</div>
</body>
</html>