Jon
Fri Feb 15 10:24:59 CST 2008
http://dypso.free.fr/tech/asp_format_date_time-en.php
"Paulo" <prbspfc@uol.com.br> wrote in message news:ezaNh0%23bIHA.1208@TK2MSFTNGP05.phx.gbl...
> Any way to optimize it ?
>
> <% sDia = ""
> sMes = ""
> sAno = ""
> sData = ""
> if not IsNull(rs("DT_EXAME")) then
> sDia = Day(rs("DT_EXAME"))
> sMes = Month(rs("DT_EXAME"))
> sAno = Year(rs("DT_EXAME"))
> if Len(sDia) = 1 then sDia = "0" & sDia
> if Len(sMes) = 1 then sMes = "0" & sMes
> sData = sDia & "/" & sMes & "/" & sAno
> end if
> %>
>
> returns the dd/mm/yyyy coming from a db date field with left-zero filled
>
> "McKirahan" <News@McKirahan.com> escreveu na mensagem news:TKSdnZ9gsJUZKyjanZ2dnUVZ_tWtnZ2d@comcast.com...
>> "Paulo" <prbspfc@uol.com.br> wrote in message
>> news:OmnBlm#bIHA.1960@TK2MSFTNGP02.phx.gbl...
>>> Any function on ASP to format date on dd/mm/yyyy?
>>> The format (VB) function does not work on ASP ?
>>
>> FormatDateTime() may meet your needs.
>>
>> VBScript FormatDateTime Function
>>
http://www.w3schools.com/vbscript/func_formatdatetime.asp
>>
>> FormatDateTime(Now,2) = 02/15/2008 (mm/dd/yyyy) for me.
>>
>> If you need dd/mm/yyyy then you may have to construct it
>> using DatePart(); for example, (where "x" is your date):
>>
>> DatePart("d",x) & "/" & DatePart("m",x) & "/" & DatePart("yyyy",x)
>>
>> Be aware that the day and month returned are not left-zero filled;
>> that is, today's date will appear as 15/2/2008 unless adjusted.
>>
>>
>
>