date value and timestamps

M

middletree

I know that if I have a full timestamp, and wrap the DateValue function
around it, it will give me mm/dd/yyyy. I can't seem to find a similar
function which would return a 2-digit year. Is there such a thing?
 
R

Ray at

AFAIK, no. Just like you can't do a formatdatetime and return "2:32 PM"
It's either "2:32:00 PM" or "14:32." I think that you'll have to manipulate
your date manually with some string manipulations or DatePart function to
return the date in the two digit year format. Just be aware that your
server may explode and your car will burst into flames when the clock
strikes midnight on the night of 12/31/2099.

Ray at work
 
R

Ray at

With default regional settings, that will also return the four digit year.

Ray at work
 
M

middletree

Thanks!


Peter Foti said:
Interesting. I was not aware of that.
In that case, the "write your own" method:

Function shortDateString( oDate )
str = month( oDate ) & "/"
str = str & day( oDate ) & "/"
str = str & right( Year( oDate ), 2 )
shortDateString = str
End Function

Response.Write( shortDateString( Date ) )

Regards,
Peter
 
D

dlbjr

This will run faster:

Function shortDateString(oDate)
If IsDate(oDate) Then
Dim ar(4)
ar(0) = Month(oDate)
ar(1) = "/"
ar(2) = Day(oDate)
ar(3) = "/"
ar(4) = Right(Year(oDate),2)
shortDateString = Join(ar,"")
End If
End Function

-dlbjr

Discerning resolutions for the alms
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top