Simple date format question from a new guy

Discussion in 'ASP .Net' started by tom c, Jul 9, 2006.

  1. tom c

    tom c Guest

    I want to put the date in Year, Month, Day format so todays date,
    7/8/2006, will give me 20060708.

    The following code code leaves out the zeros for day and month and
    gives me 200678

    Dim RptDate As String
    Dim wkDate As Date
    wkDate = Today
    RptDate = wkDate.Year & wkDate.Month & wkDate.Day

    What is the easiest way to get the format I want?
     
    tom c, Jul 9, 2006
    #1
    1. Advertising

  2. tom c

    tom c Guest

    I found the answer:

    RptDate = Format(Today, "yyyyMMdd")

    I wish they were consistent with making month lower case like year and
    day



    tom c wrote:
    > I want to put the date in Year, Month, Day format so todays date,
    > 7/8/2006, will give me 20060708.
    >
    > The following code code leaves out the zeros for day and month and
    > gives me 200678
    >
    > Dim RptDate As String
    > Dim wkDate As Date
    > wkDate = Today
    > RptDate = wkDate.Year & wkDate.Month & wkDate.Day
    >
    > What is the easiest way to get the format I want?
     
    tom c, Jul 9, 2006
    #2
    1. Advertising

  3. tom c

    Rick Strahl Guest

    Lower case m's are minutes, so there's a trade off there...

    +++ Rick ---

    --


    Rick Strahl
    West Wind Technologies
    http://www.west-wind.com/weblog
    http://www.west-wind.com/wwThreads/


    "tom c" <> wrote in message
    news:...
    >I found the answer:
    >
    > RptDate = Format(Today, "yyyyMMdd")
    >
    > I wish they were consistent with making month lower case like year and
    > day
    >
    >
    >
    > tom c wrote:
    >> I want to put the date in Year, Month, Day format so todays date,
    >> 7/8/2006, will give me 20060708.
    >>
    >> The following code code leaves out the zeros for day and month and
    >> gives me 200678
    >>
    >> Dim RptDate As String
    >> Dim wkDate As Date
    >> wkDate = Today
    >> RptDate = wkDate.Year & wkDate.Month & wkDate.Day
    >>
    >> What is the easiest way to get the format I want?

    >
     
    Rick Strahl, Jul 9, 2006
    #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. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,300
    Michael Borgwardt
    May 30, 2004
  3. Replies:
    2
    Views:
    500
  4. Macon Joe Job Guy Joe Macon Job Guy

    Att: Macon Joe Job Guy Joe Macon Job Guy Macon

    Macon Joe Job Guy Joe Macon Job Guy, Oct 14, 2007, in forum: Java
    Replies:
    0
    Views:
    380
    Macon Joe Job Guy Joe Macon Job Guy
    Oct 14, 2007
  5. Replies:
    1
    Views:
    222
    Rectal Mania
    Aug 6, 2007
Loading...

Share This Page