format date in asp

N

news

Hello,
Can someone help me with this request?
1. Data in my access database have the format "9/10 2005"
2. When I show all dates within an asp page I get the following format
"9/10/2005"

The format I want to show in my asp page is the following format "9/10-05"
!!!
Please help!!

// Kenneth
 
P

Patrice

1. If not already done store dates using the date datatype instead of
text... How they look is a formatting issue not a storage issue.

2. My personal preference is to use my own formatting function (you can use
the year, month, day function for examples)

For example Month(myDate) & "/" & Day(MyDate) & "-" & Right(Year(MyDate),2)
depending on the exact format you want would be a first step. Do this in a
function...
 
R

Roland Hall

in message : Can someone help me with this request?
: 1. Data in my access database have the format "9/10 2005"
: 2. When I show all dates within an asp page I get the following format
: "9/10/2005"
:
: The format I want to show in my asp page is the following format "9/10-05"

Two ways: assuming rs = recordset, mydate = db column name

1.

dim arrDate
if not (rs.BOF or rs.EOF) then
arrDate = split(rs("mydate"),"/")
rs.Close
set rs = nothing
conn.Close
set conn = nothing
Response.Write arrDate(0) & "/" & arrDate(1) & "-" & right(arrDate(2),2)
else
Response.Write "No records returned."
end if

2.
dim d
if not(rs.BOF or rs.EOF) then
d = CDate(rs("mydate"))
rs.Close
set rs = nothing
conn.Close
set conn = nothing
Response.Write month(d) & "/" & day(d) & "-" & right(year(d),2)
else
Response.Write "No records returned."
end if

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top