Bueno, ya que la discusion esta activada
Quisiera hacer una aclaracion, en MySQL ( que segun veo es la base de datos que se utiliza) no existe la funcion to_char que es al estilo oracle
El equivalente puede ser DATE FORMAT
<!--sql--></div><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td>
SQL </td></tr><tr><td id='CODE'><!--sql1-->[color=blue;font-weight]SELECT[/color] DATE_FORMAT(fecha,
'%d'),DATE_FORMAT(fecha,
'%m'),DATE_FORMAT(fecha,
'%Y')
FROM tabla <!--sql2--></td></tr></table><div class='postcolor'><!--sql3-->
[dohtml]
<table border='1'>
<tr style="height: 12.75pt;" height="17">
<td class="xl2313238" style="height: 12.75pt; width: 48pt;" height="17" width="64">Specifier</td>
<td class="xl2313238" style="border-left: medium none; width: 245pt;" width="327">Description</td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%a</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Abbreviated weekday name (<font class="font513238">Sun</font><font class="font013238">..</font><font class="font513238">Sat</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%b</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Abbreviated month name (<font class="font513238">Jan</font><font class="font013238">..</font><font class="font513238">Dec</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%c</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Month, numeric (<font class="font513238">0</font><font class="font013238">..</font><font class="font513238">12</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%D</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Day of the month with English suffix (<font class="font513238">0th</font><font class="font013238">, </font><font class="font513238">1st</font><font class="font013238">, </font><font class="font513238">2nd</font><font class="font013238">, </font><font class="font513238">3rd</font><font class="font013238">, ...)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%d</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Day of the month, numeric (<font class="font513238">00</font><font class="font013238">..</font><font class="font513238">31</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%e</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Day of the month, numeric (<font class="font513238">0</font><font class="font013238">..</font><font class="font513238">31</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%f</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Microseconds (<font class="font513238">000000</font><font class="font013238">..</font><font class="font513238">999999</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%H</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Hour (<font class="font513238">00</font><font class="font013238">..</font><font class="font513238">23</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%h</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Hour (<font class="font513238">01</font><font class="font013238">..</font><font class="font513238">12</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%I</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Hour (<font class="font513238">01</font><font class="font013238">..</font><font class="font513238">12</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%i</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Minutes, numeric (<font class="font513238">00</font><font class="font013238">..</font><font class="font513238">59</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%j</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Day of year (<font class="font513238">001</font><font class="font013238">..</font><font class="font513238">366</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%k</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Hour (<font class="font513238">0</font><font class="font013238">..</font><font class="font513238">23</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%l</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Hour (<font class="font513238">1</font><font class="font013238">..</font><font class="font513238">12</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%M</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Month name (<font class="font513238">January</font><font class="font013238">..</font><font class="font513238">December</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%m</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Month, numeric (<font class="font513238">00</font><font class="font013238">..</font><font class="font513238">12</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%p</td>
<td class="xl2413238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">AM<font class="font013238"> or </font><font class="font513238">PM</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%r</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Time, 12-hour (<font class="font513238">hh:mm:ss</font><font class="font013238"> followed by </font><font class="font513238">AM</font><font class="font013238"> or </font><font class="font513238">PM</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%S</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Seconds (<font class="font513238">00</font><font class="font013238">..</font><font class="font513238">59</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%s</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Seconds (<font class="font513238">00</font><font class="font013238">..</font><font class="font513238">59</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%T</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Time, 24-hour (<font class="font513238">hh:mm:ss</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%U</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Week (<font class="font513238">00</font><font class="font013238">..</font><font class="font513238">53</font><font class="font013238">), where Sunday is the
first day of the week</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%u</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Week (<font class="font513238">00</font><font class="font013238">..</font><font class="font513238">53</font><font class="font013238">), where Monday is the
first day of the week</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%V</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Week (<font class="font513238">01</font><font class="font013238">..</font><font class="font513238">53</font><font class="font013238">), where Sunday is the
first day of the week; used with </font><font class="font513238">%X</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%v</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Week (<font class="font513238">01</font><font class="font013238">..</font><font class="font513238">53</font><font class="font013238">), where Monday is the
first day of the week; used with </font><font class="font513238">%x</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%W</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Weekday name (<font class="font513238">Sunday</font><font class="font013238">..</font><font class="font513238">Saturday</font><font class="font013238">)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%w</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Day of the week (<font class="font513238">0</font><font class="font013238">=Sunday..</font><font class="font513238">6</font><font class="font013238">=Saturday)</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%X</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Year for the week where Sunday is the first day of the week,
numeric, 4 digits; used with <font class="font513238">%V</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%x</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Year for the week, where Monday is the first day of the week,
numeric, 4 digits; used with <font class="font513238">%v</font></td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%Y</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Year, numeric, 4 digits</td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%y</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">Year, numeric, 2 digits</td>
</tr>
<tr style="height: 15pt;" height="20">
<td class="xl2413238" style="border-top: medium none; height: 15pt; width: 48pt;" height="20" width="64">%%</td>
<td class="xl2213238" style="border-top: medium none; border-left: medium none; width: 245pt;" width="327">A literal <font class="font513238">`%'</font><font class="font013238">.</font>
</td>
</tr>
</table>
[/dohtml]
Saludos