Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First day of the month + 1 month should equal the first of the next month. Trying this on SQL Server</p> <pre><code> SELECT CAST ('01/01/2012' AS DateTime), DATEADD (m, 1, '01/01/2012') UNION ALL SELECT CAST ('02/01/2012' AS DateTime), DATEADD (m, 1, '02/01/2012') UNION ALL SELECT CAST ('03/01/2012' AS DateTime), DATEADD (m, 1, '03/01/2012') UNION ALL SELECT CAST ('04/01/2012' AS DateTime), DATEADD (m, 1, '04/01/2012') UNION ALL SELECT CAST ('05/01/2012' AS DateTime), DATEADD (m, 1, '05/01/2012') </code></pre> <p>This results in</p> <pre><code>----------------------- ----------------------- 2012-01-01 2012-02-01 2012-02-01 2012-03-01 2012-03-01 2012-04-01 2012-04-01 2012-05-01 2012-05-01 2012-06-01 </code></pre> <p>Last day of this month + 1 month should equal last day of next month. This should go for next month, current month, 10 months down, etc. </p> <pre><code> SELECT CAST ('01/31/2012' AS DateTime), DATEADD (m, 1, '01/31/2012') UNION ALL SELECT CAST ('01/30/2012' AS DateTime), DATEADD (m, 1, '01/30/2012') UNION ALL SELECT CAST ('01/29/2012' AS DateTime), DATEADD (m, 1, '01/29/2012') UNION ALL SELECT CAST ('01/28/2012' AS DateTime), DATEADD (m, 1, '01/28/2012') UNION ALL SELECT CAST ('01/27/2012' AS DateTime), DATEADD (m, 1, '01/27/2012') UNION ALL SELECT CAST ('01/26/2012' AS DateTime), DATEADD (m, 1, '01/26/2012') </code></pre> <p>This results in</p> <pre><code>----------------------- ----------------------- 2012-01-31 2012-02-29 2012-01-30 2012-02-29 2012-01-29 2012-02-29 2012-01-28 2012-02-28 2012-01-27 2012-02-27 2012-01-26 2012-02-26 </code></pre> <p>See how 31, 30, 29 all become feb 29 (2012 is a leap year).</p> <p>p.s. I took off the time parts (all zeroes) to help make it more readable</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload