none
going back one day before system date

    Question

  • Hi,

    I am trying to go back one day from the current day and I use this code and it gives me error.

    Sub xx()
    Dim Mydate As Date
    Mydate = Date
    Mydate = Mydate.AddDays(-1)
    End Sub

    any suggestion?

    Regards,

    Jeff P.


    Jeff Paarsa

    Monday, January 13, 2014 4:25 AM

Answers

  • Hello Jeff,

    You can use the DateSerial function to get the required date based on existing one, for example:

    Dim dteThisYear As Date   
    ' Find corresponding date
    dteThisYear = DateSerial(Year(Date), Month(Date), Day(Date)-1)
    ' actually the business logic should be complex to handle the last day in a month, decreasing the month value and setting the last day of month

    Also you can use the DateAdd function:

    DateAdd(DateInterval.Day, -1, Date)
    

    Please read more about this in the Working with Dates and Times article in MSDN.

    Finally, it looks like your question is not related to Outlook. That is why I would recommend asking such questions in the General Office Development or Visual Basic  forum instead.

    Monday, January 13, 2014 6:37 AM

All replies

  • Hello Jeff,

    You can use the DateSerial function to get the required date based on existing one, for example:

    Dim dteThisYear As Date   
    ' Find corresponding date
    dteThisYear = DateSerial(Year(Date), Month(Date), Day(Date)-1)
    ' actually the business logic should be complex to handle the last day in a month, decreasing the month value and setting the last day of month

    Also you can use the DateAdd function:

    DateAdd(DateInterval.Day, -1, Date)
    

    Please read more about this in the Working with Dates and Times article in MSDN.

    Finally, it looks like your question is not related to Outlook. That is why I would recommend asking such questions in the General Office Development or Visual Basic  forum instead.

    Monday, January 13, 2014 6:37 AM
  • Hi,

    Yes it is related to Outlook but nothing else... I receive my daily faxes in Outlook as PDF attached... I want to start the Outlook exactly at 12:00 A.M. and just strip off the PDF faxes from item that has been sent only the day before not any faxes has received after 12:00 A.M.  the day/date that Outlook has started...

    One of the problem I have is that to stop the Outlook after  I received the faxes for yesterday... I used Timer but due to a known issue the very First item with PDF attached is not processed.  I was told that is a known issue to Outlook... So far every tricks I have been told to use I have but each one has problem of it's own.

    I schedule the timer and the Stripping rule when I wake up I notice a dialog has been opened by Outlook stating that Outlook can not quit because Stripping rule is running and the first Item still has it's PDF attached and in the Inbox...  I have to run the rule for stripping one more time and off course that brings in a lot of faxes from the day of running outlook that I do not want to come in... Believe me it is a dilemma that I have been struggling for the last 2-3 months.

    Regards,

    Jeff P.

     


    Jeff Paarsa

    Tuesday, January 14, 2014 3:41 AM
  • Hello Jeff,

    What known issue are you talking about?

    Anyway, it looks like your post is not related to the initial question. That is why I'd suggest creating new threads instead. Thus, future forum readers can locate answers easily.

    Tuesday, January 14, 2014 2:06 PM
  • Hi Eugene,

    That issue you yourself told me about that is a known issue... Faxing issue that you gave me suggestion... remember...  look at this...

    http://social.msdn.microsoft.com/Forums/office/en-US/dc11b0c8-baaa-4a29-af78-43f05723eec2/i-am-almost-positive-this-is-a-bug-in-outlook-2010?forum=outlookdev

    Rule Not processing first item as it comes in...

    Regards,

    Jeff P. 


    Jeff Paarsa

    Thursday, January 16, 2014 3:22 AM
  • Hi Jeff,

    Please take a look at the forum thread you are referring to:

    Note, if you receive 16 or more items at once, the NewMail event does not fire. Also you may miss some items in case of the NewMailEx event. This is a well-known issue when dealing with the Outlook Object Model. You can read more about this in the Outlook NewMail event unleashed: the challenge (NewMail, NewMailEx, ItemAdd) article.

    The NewMail and NewMailEx events were described. The issue is not related to Outlook rules.

    Thursday, January 16, 2014 8:48 AM