Hello SOF community:
I have a table like this
InvoicingActivityStartDay InvoicingActivityEndDay
27 26
27 26
01 NULL --NULL MEANS LAST DAY OF MONTH
01 NULL
15 14
I need a T-SQL query that will return the following for the data above, given the current date; if current date = 12-JAN-2012, the results should be as below
InvoicingActivityStartDATE InvoicingActivityEndDATE
27-DEC-2011 12:00:00.000 26-JAN-2012 23:59:99.999
27-DEC-2011 12:00:00.000 26-JAN-2012 23:59:99.999
01-DEC-2011 12:00:00.000 31-DEC-2011 23:59:99.999
01-DEC-2011 12:00:00.000 31-DEC-2011 23:59:99.999
15-DEC-2011 12:00:00.000 14-JAN-2012 23:59:99.999
Can you please show me how this be done in a single query?
Please note that if the start day is 1, that means the end day is always the last day of the previous month.
If I interpret your requirements correctly (that the start day is that day of last month, and the end day is that day of this month; except when start day is 1), then you may want something like this (assuming your start/end days are integers; if not, cast them as ints):