dave_ie
asked on
DateTime conversion to String
hi
i have a problem (as always)
i have an access database field with a Date/Time field, now all i want to do is convert it to a string.
i retrive the value from the database with an
RS.Fields("post_date") statement etc. so how can i declare a variable string to hold the string representation of that datetime field ?????
can anyone help me ?????
if its any help heres my attempt at the asp code
<%
Dim strDate
strDate = String(Date(RS.Fields,"pos t_date"))) ',"dd/mm/y y")
Response.Write(strDate)
%>
thanks in advance guys
dave
i have a problem (as always)
i have an access database field with a Date/Time field, now all i want to do is convert it to a string.
i retrive the value from the database with an
RS.Fields("post_date") statement etc. so how can i declare a variable string to hold the string representation of that datetime field ?????
can anyone help me ?????
if its any help heres my attempt at the asp code
<%
Dim strDate
strDate = String(Date(RS.Fields,"pos
Response.Write(strDate)
%>
thanks in advance guys
dave
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Actually, I see what you need to do now. Try
datevar = day(rs("Post_Date")) & "/" & month(rs("Post_Date")) & "/" & right(Year(rs("Post_Date") ,2)
strdate = CSTR(datevar)
response.write strdate
Should work....
datevar = day(rs("Post_Date")) & "/" & month(rs("Post_Date")) & "/" & right(Year(rs("Post_Date")
strdate = CSTR(datevar)
response.write strdate
Should work....
ASKER
thx a lot for that shane
dave
dave
<%
Dim strDate
strDate = FormatDate(now(),2)
Response.Write(strDate)
%>
To see all possble formats run the following ASP script
<html><head>
<title>formatdates.asp</ti
</head><body bgcolor="#FFFFFF"><html>
<%'My ASP program that formats dates
response.write "<hr>"
for counter=0 to 4
currentdate=now()
response.write "today is..." & "<br>"
response.write currentdate & "<P>"
select case counter
case 0
whichformat="vbgeneraldate
case 1
whichformat="vblongdate"
case 2
whichformat="vbshortdate"
case 3
whichformat="vblongtime"
case 4
whichformat="vbshorttime"
end select
response.write "FormatDate(now()," & whichformat & ")="
response.write Formatdatetime(currentdate
next%>
</body></html>
regards
GK