Was this page helpful?

Date.DiffDays

    Table of contents
    1. 1. Usage Restrictions
    2. 2. Parameters
    3. 3. Result
    4. 4. Samples
    date.DiffDays(first : str, second : str) : num

    Compute the difference between the first and second date in days. 

    Usage Restrictions

    1.9.1 or later.

    Parameters

    Name Type Description
    first
    str The first date.
    second
    str
    The second date.

    Result

    The difference between the first and second date in days.

    Samples


    Output

    To display the difference in days between today and a month from now:

    {{ date.DiffDays(date.now, date.AddMonths(date.now, 1)) }} 

    -31

    To display the difference in days between today and 01/01/2000:

    {{ date.DiffDays(date.now, "01/01/2000") }} 

    4528.34074074074

    Was this page helpful?
    Tag page
    Viewing 3 of 3 comments: view all
    Using Date.DiffDays for an Intranet is really useful - however to return "it's 12.2321321 days before the next pay day" looks rubbish - can you advise in your second example (given above) how to only return a whole number please?
    Posted 07:12, 30 Jun 2008
    Have a look at the number functions (http://wiki.developer.mindtouch.com/MindTouch_Deki/DekiScript/Reference/DekiScript_Functions_and_Variables#Number_Functions), and you'll see num.floor(), which will do what you want. Just wrap it around the above code to return an int:

    "{{ num.floor(date.diffdays(paydaydate, date.now)) }} days before the next pay day" edited 11:37, 28 Jul 2008
    Posted 11:37, 28 Jul 2008
    The reason for this behavior is that it's no uncommon to want to show something like "X days, Y hours, Z minutes" until an event.
    Posted 12:23, 28 Jul 2008
    Viewing 3 of 3 comments: view all
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by