none
DateDiff not work in vbscript RRS feed

  • Question

  • I found some script not working after migrated to Outlook 2013.

    Example 1) DateDiff("d", INPUT_DATE, Now())

    Example 2) Message.UserProperties.add("customField", olText)

    Please suggest how to use the function in Outlook 2013 via vbs, thanks.


    • Edited by _dson Wednesday, April 13, 2016 8:47 AM DateDiff
    Wednesday, April 13, 2016 6:56 AM

Answers

  • You must use Now correctly:

    days =  DateDiff("d", Now-10, Now)
    WScript.Echo days


    \_(ツ)_/

    • Marked as answer by _dson Thursday, April 14, 2016 1:50 AM
    Wednesday, April 13, 2016 8:56 AM

All replies

  • VBScript does  bot work in Outlook. You example also make no sense. Please post Outlook VBA questions in the Outlook Developer forum.

    VBScript on message edir controls also is handled in Ouyloo developer forum.  VBScript in Outlook has been disable or reduced in function in Outlook 2013 and later.

    See: https://msdn.microsoft.com/en-us/library/office/ff866953.aspx?f=255&MSPPError=-2147217396

    Post here: https://msdn.microsoft.com/en-us/library/office/ff866953.aspx?f=255&MSPPError=-2147217396


    \_(ツ)_/

    Wednesday, April 13, 2016 7:23 AM
  • Thanks, but I not using on Outlook form. I would like to create a script (current is using .vbs) to handle email between public folder. The DateDiff and UserProperties.Add function is works on Outlook 2003 via vbs.
    Wednesday, April 13, 2016 7:33 AM
  • VBScript with .vbs is not part of Outlook.  VBScript DateDiff has not changed.

    Without a specific error message there is no way to know what you are asking.


    \_(ツ)_/

    Wednesday, April 13, 2016 7:53 AM
  • Set p = Message.UserProperties.add("customField", 1)


    \_(ツ)_/


    • Edited by jrv Wednesday, April 13, 2016 8:12 AM
    Wednesday, April 13, 2016 8:11 AM
  • Thanks, I got the "Microsoft VBScript runtime error", Error: Object required: 'DateDiff(...)'.

    It works in Outlook 2003 environment, but fail in Outlook 2013

    Wednesday, April 13, 2016 8:11 AM
  • Thanks, I got the "Microsoft VBScript runtime error", Error: Object required: 'DateDiff(...)'.

    It works in Outlook 2003 environment, but fail in Outlook 2013

    DateDiff has nothing to do with Outlook,  It is a VBScript function.

    days = DateDiff( "d", INPUT_DATE, Now)

    INPUT_DATE must be a date object or you will get that error.  I suspect you have copied the code incorrectly.


    \_(ツ)_/

    Wednesday, April 13, 2016 8:18 AM
  • Do I need format the date?

    days = DateDiff( "d", "13/04/2016", Now)

    Wednesday, April 13, 2016 8:37 AM
  • I also try DateDiff("d", Now()-1, Now()), but got the same error.
    Wednesday, April 13, 2016 8:38 AM
  • You must use Now correctly:

    days =  DateDiff("d", Now-10, Now)
    WScript.Echo days


    \_(ツ)_/

    • Marked as answer by _dson Thursday, April 14, 2016 1:50 AM
    Wednesday, April 13, 2016 8:56 AM