Results 1 to 6 of 6

Thread: Dates...

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2013
    Location
    Minneapolis, MN
    Posts
    531

    Dates...

    Hello:

    How can I get the date to show up as just the date?
    Code:
                    EstDate = DateAdd("d", Days, Now)
                    EstDate = Format(EstDate, "m d yyyy")
    Shows:
    Code:
    10/23/2020  12:00:00 AM
    I'd like to lose the time.

    Thanks!
    - A 'Hyperactive Member' trying to make a difference in a hyperactive world! And recently, I've been promoted to a 'Finatic Member,' whatever that means!

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,871

    Re: Dates...

    How is EstDate declared.
    How do you show the content of EstDate?
    If EstDate is a date variable your code will not do what you expect

  3. #3
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,415

    Re: Dates...

    Why not just use the predefined Formats?
    Debug.print Format(Now, "Short Date")
    Or the FormatDateTime-Function?
    Debug.Print FormatDateTime(Cstr(EstDate),vbShortDate)
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  4. #4
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    759

    Re: Dates...

    I'd wager that EstDate is defined "As Date".

    You take the (Date) value of Now(), add a number of days to it (still a Date), then format that into a String value and assign it back into EstDate (a Date).

    Dates are displayed with times.

    Now, try it with sEstDate defined "as String":
    Code:
    sEstDate = Format$( DateAdd( "d", days, Now(), "d m yyyy" )
    Regards, Phill W.

  5. #5
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    4,415

    Re: Dates...

    Urggghhh.....forgot about the implicit Type-Cast

    Nevermind, that you should never save a Date/Time-value in a String-Variable.
    Just use Format (which returns a string) to assign/show/display whatever date you want
    Last edited by Zvoni; Tomorrow at 31:69 PM.
    ----------------------------------------------------------------------------------------

    One System to rule them all, One Code to find them,
    One IDE to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    Code is like a joke: If you have to explain it, it's bad

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Dates...

    There is no "cast" only an implicit conversion, also known as coercion.

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