• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Subtracting one day from date

PipBoy808

Member
I thought this was one of those things I knew how to do, but I was wrong.

How does one subtract a single day from a date in VBA?

Code:
Dim MyDate as Date
 
MyDate = "03/06/2014"
 
MyDate = MyDate - 1 'error

Help would be much appreciated! :)
 
@PipBoy808,

Replace the last two lines shown above with the following:
MyDate = DateSerial(2014, 3, 6) - 1

It will then return the date of the previous day. If you need to keep the entered date and calculation separate, then you can use the two line approach as you have done, but replace the string with the DateSerial function.

Hope that helps.

Regards,
Ken
 
Hi pipboy..

Your code is perfectly working fine in here..:oops:

upload_2014-6-3_23-39-6.png

Can you please confirm.. what error you are facing..
 
Back
Top