format date in asp

Discussion in 'ASP General' started by news, Nov 22, 2005.

  1. news

    news Guest

    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
    news, Nov 22, 2005
    #1
    1. Advertising

  2. news

    Patrice Guest

    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...

    --
    Patrice

    "news" <> a écrit dans le message de
    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
    >
    >
    Patrice, Nov 22, 2005
    #2
    1. Advertising

  3. news

    Roland Hall Guest

    "news" wrote in message news:...
    : 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
    Roland Hall, Nov 22, 2005
    #3
  4. news

    PJones Guest

    http://www.powerasp.com/content/new/formating-date-and-time.asp


    "news" <> wrote in message
    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
    >
    PJones, Nov 27, 2005
    #4
    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. Brian Candy
    Replies:
    2
    Views:
    1,137
    Janaka
    Feb 18, 2004
  2. DC
    Replies:
    5
    Views:
    2,988
    Brendan Reynolds
    Jul 1, 2005
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,194
    Michael Borgwardt
    May 30, 2004
  4. Chu
    Replies:
    3
    Views:
    4,164
    Shawn
    Aug 15, 2006
  5. Josh Sharpe
    Replies:
    1
    Views:
    195
    Brian Candler
    Sep 21, 2010
Loading...

Share This Page