Discussion:
More dates issues
(too old to reply)
Ana
2008-01-23 09:05:15 UTC
Permalink
Hello all,

I'm stumble on a project so I would appreciate someone's help.

I've a company which sells several service contracts everyday with duration
from one to 36 months. The tbl parameters are as follows:

ID, cost, activation_date, start_date, end_date .. among many other fields.

The idea is to create a query/report outputting daily and monthly cost
information considering the leap year.

Example, today's daily report if starting today: sum(cost) / contract
period in days where start_date = getdate()

Example, tomorrows' daily report if starting today: (today's results -1) +
(sum(cost) / contract period in days where start_date = getdate())

Hope I've being clear. TIA

Ana
Dejan Sarka
2008-02-05 17:07:41 UTC
Permalink
Do please check a wonderful article on auxiliary calendar table at
http://sqlserver2000.databases.aspfaq.com/why-should-i-consider-using-an-auxiliary-calendar-table.html. I
guess you will get an idea how to solve your problem.
--
Dejan Sarka
http://blogs.solidq.com/EN/dsarka/default.aspx
Post by Ana
Hello all,
I'm stumble on a project so I would appreciate someone's help.
I've a company which sells several service contracts everyday with
ID, cost, activation_date, start_date, end_date .. among many other fields.
The idea is to create a query/report outputting daily and monthly cost
information considering the leap year.
Example, today's daily report if starting today: sum(cost) / contract
period in days where start_date = getdate()
Example, tomorrows' daily report if starting today: (today's results -1)
+ (sum(cost) / contract period in days where start_date = getdate())
Hope I've being clear. TIA
Ana
Loading...