Results 1 to 12 of 12

Thread: Format a date

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 1999
    Location
    Belgium
    Posts
    98

    Post

    Hello,

    How can I format a date ? the result must be
    "dd/mm/yy"

    for example:

    Dim MyDate as Date

    MyDate = Now()

    The result is always "dd/mm/yy hh:mm:ss"

    How can dump the "hh:mm:ss" ?

    R@emdonck

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    Look up the Format function in Help. One of the "named" (built-in) formats for dates is Short Date and it's used like thisMsgBox Format(Now(), "Short Date")

    ------------------
    Marty

  3. #3
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    This seems to work:
    Code:
    Dim MyDate As Date
    MyDate = Format(Now, "hh:mm:ss")
    ------------------
    Visual Basic Programmer
    ------------------
    PolComSoft
    You will hear a lot about it.


  4. #4
    Member
    Join Date
    Dec 1999
    Posts
    37

    Post

    This uses the format string "m/d/yy", which displays the month, day, and a two-digit year.

    Code:
    Dim MyDate As Date
    MyDate = Now()
    Text1.Text = Format(MyDate, "m/d/yy")

    [This message has been edited by Ruchi (edited 12-13-1999).]

  5. #5
    Lively Member
    Join Date
    Nov 1999
    Posts
    98

    Post

    here are many formats you can use:

    d = one digit date
    dd = two digit date
    ddd = abbreviated day name
    dddd = full day name

    m - one digit month
    mm = two digit month
    mmm = abbreviated month name
    mmmm = full month name

    yy = two digit year
    yyyy = four digit year

    use any of those formats with wach other in this code:

    Text1.Text = Format(MyDate, see above formats)

    for instance...
    Text1.Text = Format(MyDate, dd/mm/yy)
    will return 27/01/99

    or

    Text1.Text = Format(MyDate, dddd mmm dd, yyyy)
    will return Wednesday Jan 27, 1999

    hope this all helps. happy programming!!

    --michael

  6. #6
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,253

    Re: Password Hashing and Salt

    Please delete, replied to wrong thread
    Last edited by PlausiblyDamp; Nov 22nd, 2017 at 08:41 PM.

  7. #7
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,453

    Re: Format a date

    What year is it in Newport, UK?

  8. #8
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    869

    Re: Format a date

    Maybe 19 days after the OP and just before you know what

  9. #9
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,253

    Re: Format a date

    oops, didn't see the replies - I have no idea what happened as I replied to a different thread and somehow my response appeared there and on this one

  10. #10
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,453

    Re: Format a date

    Quote Originally Posted by Spooman View Post
    Maybe 19 days after the OP and just before you know what
    Morning spoo...my point was this thread is 18 YEARS old (started and ended in 1999---a great album by Prince (or whatever name he now goes by), btw). But now I see our English friend PD's post was a mistake.

  11. #11
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    869

    Re: Format a date

    Back at ya, Sammi. I was making a loose reference to the Y2K issue .. read as time-warp.

  12. #12
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,446

    Re: Format a date

    Prince died last year. Are we still doing the Time Warp in this thread or what?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width