<%=date%> (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


box -> <%=date%> (2/3/2008 18:49:54)

<%=date%> gives 2/3/2008 format I need to get 02/03/2008 format any idea please?




rdouglass -> RE: <%=date%> (2/4/2008 13:39:48)

<% function fixTheDate(dateIn)
tempText = ""
If IsDate(dateIn) Then

If len(DatePart("d",dateIn)) = 1 Then
tempText = tempText & "0" & DatePart("d",dateIn) & "/"
Else
tempText = tempText & DatePart("d",dateIn) & "/"
End If

If len(DatePart("m",dateIn)) = 1 Then
tempText = tempText & "0" & DatePart("m",dateIn) & "/"
Else
tempText = tempText & DatePart("m",dateIn) & "/"
End If

fixTheDate = tempText & DatePart("yyyy",dateIn)

else ' if not a date, send back an empty string

fixTheDate = ""

end if
end function

response.write(fixTheDate(Date())
%>


Something like that maybe?




box -> RE: <%=date%> (2/6/2008 2:41:57)

Thanks, it works great, the problem is if I use it as hidden value in the form I get syntax error!!![&:]
<% function fixTheDate(dateIn)
tempText = ""
If IsDate(dateIn) Then

If len(DatePart("d",dateIn)) = 1 Then
tempText = tempText & "0" & DatePart("d",dateIn) & "/"
Else
tempText = tempText & DatePart("d",dateIn) & "/"
End If

If len(DatePart("m",dateIn)) = 1 Then
tempText = tempText & "0" & DatePart("m",dateIn) & "/"
Else
tempText = tempText & DatePart("m",dateIn) & "/"
End If

fixTheDate = tempText & DatePart("yyyy",dateIn)

else ' if not a date, send back an empty string

fixTheDate = ""

end if
end function

response.write(fixTheDate(Date()))
%>








rdouglass -> RE: <%=date%> (2/6/2008 8:31:07)

quote:

the problem is if I use it as hidden value in the form I get syntax error!!!


What specifically is the error and what is the line it errors on?




box -> RE: <%=date%> (2/6/2008 18:22:37)

Thanks rdouglass for reply here is the error:

Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/ep/user/pt_update.asp, line 457
function fixTheDate(dateIn)

My form display data form access DB using DRW! even I did try using it as regular text box I got the same error.[:o]




rdouglass -> RE: <%=date%> (2/6/2008 18:46:37)

You're not putting that whole thing in the textbox value are you? You'd put the function itself at the top of the page and call it where you need to fix that date.

Can you post the code and show me how you're using it? The 10 or 15 lines above and below as well if you please.




box -> RE: <%=date%> (2/7/2008 1:29:20)

Thanks a lot is working great now,

<%response.write(fixTheDate(Date()))%>




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625