-
Oct 22nd, 2020, 04:17 PM
#1
Thread Starter
Fanatic Member
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!
-
Oct 22nd, 2020, 04:19 PM
#2
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
-
Oct 23rd, 2020, 12:57 AM
#3
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
-
Oct 23rd, 2020, 06:05 AM
#4
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.
-
Oct 23rd, 2020, 08:14 AM
#5
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
-
Oct 23rd, 2020, 09:15 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|