date value and timestamps

Discussion in 'ASP General' started by middletree, Nov 25, 2003.

  1. middletree

    middletree Guest

    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?
    middletree, Nov 25, 2003
    #1
    1. Advertising

  2. middletree

    Ray at Guest

    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" <> wrote in message
    news:...
    > 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?
    >
    >
    Ray at, Nov 25, 2003
    #2
    1. Advertising

  3. middletree

    Ray at Guest

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

    Ray at work

    "Peter Foti" <> wrote in message
    news:...
    > "middletree" <> wrote in message
    > news:...
    > > 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
    >
    >
    Ray at, Nov 25, 2003
    #3
  4. middletree

    middletree Guest

    Thanks!


    "Peter Foti" <> wrote in message
    news:...
    > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > news:...
    > > With default regional settings, that will also return the four digit

    year.
    > >
    > > Ray at work
    > >
    > > "Peter Foti" <> wrote in message
    > > news:...
    > > > "middletree" <> wrote in message
    > > > news:...
    > > > > 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
    >
    >
    middletree, Nov 25, 2003
    #4
  5. middletree

    dlbjr Guest

    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
    dlbjr, Nov 25, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,197
    Michael Borgwardt
    May 30, 2004
  2. milkyway

    Filnames and timestamps

    milkyway, Sep 13, 2005, in forum: C Programming
    Replies:
    8
    Views:
    424
    Irrwahn Grausewitz
    Sep 19, 2005
  3. Phil Tomson
    Replies:
    4
    Views:
    422
    Phil Tomson
    Jun 22, 2004
  4. Xeno Campanoli
    Replies:
    2
    Views:
    139
    Tim Pease
    Apr 17, 2008
  5. Dave Saville

    Oddity with File::Find and timestamps

    Dave Saville, Dec 24, 2010, in forum: Perl Misc
    Replies:
    12
    Views:
    150
    Ilya Zakharevich
    Dec 28, 2010
Loading...

Share This Page