Any function on ASP to format date on dd/mm/yyyy?
The format (VB) function does not work on ASP ?

Thanks!

Re: Date format by McKirahan

McKirahan
Fri Feb 15 09:57:56 CST 2008

"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.



Re: Date format by Paulo

Paulo
Fri Feb 15 10:07:33 CST 2008

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.
>
>



Re: Date format by Jon

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.
>>
>>
>
>



Re: Date format by McKirahan

McKirahan
Fri Feb 15 10:40:39 CST 2008

"Paulo" <prbspfc@uol.com.br> wrote in message
news:ezaNh0#bIHA.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

[snip]

Please don't top post as it makes the conversation harder to follow.

Try this untested code:

<%
Response.Write rs("DT_EXAME") & " = " & MDY(rs("DT_EXAME"))

Function MDY(DT)
MDY = ""
If IsDate(DT) Then
MDY = Right(100+Day(DT),2) & "/" _
& Right(100+Month(DT),2) & "/" & Year(DT)
End If
End Function
%>



Re: Date format by McKirahan

McKirahan
Fri Feb 15 10:50:22 CST 2008

"Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot com> wrote in message
news:13rbf6s719a64c5@corp.supernews.com...
> http://dypso.free.fr/tech/asp_format_date_time-en.php

[snip]

Interesting idea; however, the following

<%
Response.Write "<li>" & FormatDateTime(Now,2)
Session.lcid=2057 '= UK English
Response.Write "<li>" & FormatDateTime(Now,2)
Session.lcid=1033 '= US English
Response.Write "<li>" & FormatDateTime(Now,2)
%>

returned (for me):

2/15/2008
15/02/08
2/15/2008



Re: Date format by Bob

Bob
Fri Feb 15 11:06:14 CST 2008

Paulo wrote:
> Any function on ASP to format date on dd/mm/yyyy?
> The format (VB) function does not work on ASP ?
>
http://www.aspfaq.com/show.asp?id=2313 vbscript
http://www.aspfaq.com/show.asp?id=2040 help with dates


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.



Re: Date format by Jon

Jon
Fri Feb 15 11:23:41 CST 2008

http://www.w3schools.com/asp/prop_lcid.asp





"McKirahan" <News@McKirahan.com> wrote in message news:odKdnU_-1uNTXyjanZ2dnUVZ_gmdnZ2d@comcast.com...
> "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot com> wrote in message
> news:13rbf6s719a64c5@corp.supernews.com...
>> http://dypso.free.fr/tech/asp_format_date_time-en.php
>
> [snip]
>
> Interesting idea; however, the following
>
> <%
> Response.Write "<li>" & FormatDateTime(Now,2)
> Session.lcid=2057 '= UK English
> Response.Write "<li>" & FormatDateTime(Now,2)
> Session.lcid=1033 '= US English
> Response.Write "<li>" & FormatDateTime(Now,2)
> %>
>
> returned (for me):
>
> 2/15/2008
> 15/02/08
> 2/15/2008
>
>



Re: Date format by Evertjan

Evertjan
Fri Feb 15 11:31:43 CST 2008

McKirahan wrote on 15 feb 2008 in microsoft.public.inetserver.asp.general:

> <%
> Response.Write rs("DT_EXAME") & " = " & MDY(rs("DT_EXAME"))
>
> Function MDY(DT)
> MDY = ""
> If IsDate(DT) Then
> MDY = Right(100+Day(DT),2) & "/" _
> & Right(100+Month(DT),2) & "/" & Year(DT)
> End If
> End Function
> %>
>

<%

response.write dateToString(#2008-02-15#, "dd/mm/yyyy") & "<br>"
response.write dateToString(#2008-02-16#, "m/d/yyyy")

function dateToString(d, frmt)
aF = split(frmt,"/")
for i=0 to 2
if aF(i) = "d" then aF(i) = day(d)
if aF(i) = "dd" then aF(i) = right("0"&day(d),2)
if aF(i) = "m" then aF(i) = month(d)
if aF(i) = "mm" then aF(i) = right("0"&month(d),2)
if aF(i) = "yyyy" then aF(i) = year(d)
next
dateToString= join(aF,"/")
end function

%>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: Date format by Jon

Jon
Fri Feb 15 11:52:00 CST 2008

also see this:

http://www.4guysfromrolla.com/webtech/041001-1.shtml



"Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot com> wrote in message news:13rbiku4vh38g58@corp.supernews.com...

> http://www.w3schools.com/asp/prop_lcid.asp
>
>
>
>
>
> "McKirahan" <News@McKirahan.com> wrote in message news:odKdnU_-1uNTXyjanZ2dnUVZ_gmdnZ2d@comcast.com...
>> "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot com> wrote in message
>> news:13rbf6s719a64c5@corp.supernews.com...
>>> http://dypso.free.fr/tech/asp_format_date_time-en.php
>>
>> [snip]
>>
>> Interesting idea; however, the following
>>
>> <%
>> Response.Write "<li>" & FormatDateTime(Now,2)
>> Session.lcid=2057 '= UK English
>> Response.Write "<li>" & FormatDateTime(Now,2)
>> Session.lcid=1033 '= US English
>> Response.Write "<li>" & FormatDateTime(Now,2)
>> %>
>>
>> returned (for me):
>>
>> 2/15/2008
>> 15/02/08
>> 2/15/2008
>>
>>
>
>