470,591 Members | 2,083 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,591 developers. It's quick & easy.

date value and timestamps

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?
Jul 19 '05 #1
7 3102
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

"middletree" <mi********@htomail.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
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?

Jul 19 '05 #2
"middletree" <mi********@htomail.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
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?


FormatDateTime( Date, VBShortDate )

Regards,
Peter Foti
Jul 19 '05 #3
With default regional settings, that will also return the four digit year.

Ray at work

"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vs************@corp.supernews.com...
"middletree" <mi********@htomail.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
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?


FormatDateTime( Date, VBShortDate )

Regards,
Peter Foti

Jul 19 '05 #4
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:eZ**************@tk2msftngp13.phx.gbl...
With default regional settings, that will also return the four digit year.

Ray at work

"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vs************@corp.supernews.com...
"middletree" <mi********@htomail.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
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?


FormatDateTime( Date, VBShortDate )

Regards,
Peter Foti


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
Jul 19 '05 #5
Thanks!
"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vs************@corp.supernews.com...
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:eZ**************@tk2msftngp13.phx.gbl...
With default regional settings, that will also return the four digit year.

Ray at work

"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vs************@corp.supernews.com...
"middletree" <mi********@htomail.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
> 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?

FormatDateTime( Date, VBShortDate )

Regards,
Peter Foti


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

Jul 19 '05 #6
Just construct it yourself:

sDate = Date
sMonth = DatePart("m", sDate )
sDay = DatePart("d", sDate )
If sMonth < 10 Then
sMonth = "0" & sMonth
End If
If sDay < 10 Then
sDay = "0" & sDay
End If
sFormattedDate = sMonth & "/" & sDay & "/" & Right(DatePart("yyyy", sDate),
2)

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:eZ**************@tk2msftngp13.phx.gbl...
With default regional settings, that will also return the four digit year.

Ray at work

"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vs************@corp.supernews.com...
"middletree" <mi********@htomail.com> wrote in message
news:Ot**************@TK2MSFTNGP11.phx.gbl...
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?


FormatDateTime( Date, VBShortDate )

Regards,
Peter Foti


Jul 19 '05 #7
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
Jul 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by lkrubner | last post: by
1 post views Thread by Jim | last post: by
2 posts views Thread by jrthor2 | last post: by
3 posts views Thread by dave | last post: by
3 posts views Thread by mantrid | last post: by
8 posts views Thread by Rob Wilkerson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.