format date

Discussion in 'ASP General' started by JT, Oct 6, 2003.

  1. JT

    JT Guest

    i have a date stored in my db in this format: 2005-03-15 00:00:00.000

    however, i want to display this date on my .asp page in this format: 03/05

    is there a quick function to do this?

    tmia

    jt
     
    JT, Oct 6, 2003
    #1
    1. Advertising

  2. JT

    Ray at Guest

    sDate = "2005-03-15 00:00:00.000"
    sDate = Split(sDate, " ")(0)
    sDate = Right("0" & Month(sDate), 2) & "/" & Right("0" & Day(sDate), 2)
    Response.write sDAte

    Ray at work


    "JT" <> wrote in message
    news:...
    > i have a date stored in my db in this format: 2005-03-15 00:00:00.000
    >
    > however, i want to display this date on my .asp page in this format:

    03/05
    >
    > is there a quick function to do this?
    >
    > tmia
    >
    > jt
    >
    >
     
    Ray at, Oct 6, 2003
    #2
    1. Advertising

  3. > i have a date stored in my db in this format: 2005-03-15 00:00:00.000

    Stored in what db, SQL Server? This is not how it's stored. Internally,
    it's stored as two integer values (one for the date, and one for the time).
    What you are seeing is some client tool's representation format (Enterprise
    Manager, perhaps?).

    To get it out the way you like, you can handle the formatting on the client
    as Ray suggests, or you can handle it in the database as follows:

    SELECT RIGHT('0'+RTRIM(MONTH(someColumn)), 2)
    + '/' + RIGHT('0'+RTRIM(YEAR(someColumn)), 2)
    FROM someTable
     
    Aaron Bertrand - MVP, Oct 6, 2003
    #3
    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,177
    Janaka
    Feb 18, 2004
  2. DC
    Replies:
    5
    Views:
    3,021
    Brendan Reynolds
    Jul 1, 2005
  3. Peter Grison

    Date, date date date....

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

Share This Page