Home Forums Programming General displaying 2 values when field same RE: displaying 2 values when field same

  • rmcguire 28206 - Thursday, March 23, 2017 11:26 AM

    can you explain why in:

    sPU.actual_departure >= dateadd(mm, datediff(mm, 0, getdate()), 0)

    you would write as

    sPU.actual_departure >= dateadd(mm, datediff(mm, 0, getdate()), -1)  to get the previous month?

    thank you for the help on this again

    It's because 0 is shorthand for 1900-01-01 and -1 is shorthand for 1899-12-31.  Since -1 is the end of the month before 0, this calculation will produce the end of the month before the current date.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA