Retroceder   Foros del Web > Programación para sitios web > Bases de Datos

Respuesta
 
Herramientas Desplegado
Antiguo 16-nov-2004, 12:45   #1 (permalink)
g3nius ha deshabilitado el karma
 
Fecha de Ingreso: noviembre-2004
Mensajes: 1
formato de la fecha en mySql

Tengo una tabla en mysql en la qual uno de los campos es del tipo "date", en el que la fecha fijada es la actual en el momento de la creación. El problema es que la fecha que me guarda es del tipo 2004-10-08 y no se como se cambia para que sea con formato dd-mm-aaaa.
g3nius está desconectado   Responder Citando
Antiguo 16-nov-2004, 13:44   #2 (permalink)
claudiovega está en el buen camino
 
Fecha de Ingreso: octubre-2003
Ubicación: Puerto Montt
Mensajes: 3.426
No se cambia, se usa asi.
Lo que debes hacer es que al momento de mostrar la fecha, para un informe por ejemplo, la formateas segun sea lo que requieras.
claudiovega está desconectado   Responder Citando
Antiguo 16-nov-2004, 14:06   #3 (permalink)
j_aspillaga está en el buen camino
 
Fecha de Ingreso: septiembre-2003
Mensajes: 248
Enviar un mensaje por Yahoo  a j_aspillaga
Hola, se usa date_format
DATE_FORMAT(tucampodefecha,formato)
los formatos van entre comillas simples y pueden ser:


%M Month name (January..December)
%W Weekday name (Sunday..Saturday)
%D Day of the month with English suffix (0th, 1st, 2nd, 3rd, etc.)
%Y Year, numeric, 4 digits
%y Year, numeric, 2 digits
%X Year for the week where Sunday is the first day of the week, numeric, 4 digits, used with '%V'
%x Year for the week, where Monday is the first day of the week, numeric, 4 digits, used with '%v'
%a Abbreviated weekday name (Sun..Sat)
%d Day of the month, numeric (00..31)
%e Day of the month, numeric (0..31)
%m Month, numeric (00..12)
%c Month, numeric (0..12)
%b Abbreviated month name (Jan..Dec)
%j Day of year (001..366)
%H Hour (00..23)
%k Hour (0..23)
%h Hour (01..12)
%I Hour (01..12)
%l Hour (1..12)
%i Minutes, numeric (00..59)
%r Time, 12-hour (hh:mm:ss [AP]M)
%T Time, 24-hour (hh:mm:ss)
%S Seconds (00..59)
%s Seconds (00..59)
%p AM or PM
%w Day of the week (0=Sunday..6=Saturday)
%U Week (00..53), where Sunday is the first day of the week
%u Week (00..53), where Monday is the first day of the week
%V Week (01..53), where Sunday is the first day of the week. Used with '%X'
%v Week (01..53), where Monday is the first day of the week. Used with '%x'
%% A literal `%'.

ejemplo: para q te retorne dia/mes/año
$res=mysql_query("select conDATE_FORMAT(fecha ,'%d / %m / %Y'),
from tutabla ");

saludos

Jose A.
j_aspillaga está desconectado   Responder Citando
Respuesta

Calificación: Calificación de Tema: 1 votos, 5,00 de promedio.


Herramientas
Desplegado

Normas de Publicación
No puedes crear nuevos temas
No puedes responder temas
No puedes subir archivos adjuntos
No puedes editar tus mensajes

BB code is Activado
Caritas están Activado
[IMG] está Activado
Código HTML está Desactivado


La Zona horaria es GMT -6. Ahora son las 07:06.


Message Board Statistics

LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93