Counting the month's days between two dates

Mr.Access

Registered User.
Local time
Today, 12:44
Joined
Jan 28, 2007
Messages
47
Hi All,

I wanna create a query in vb.net related to SQL 2005 that gives me the number of days the employee spent or will in a specific month depending on the Contract period as follow:

* The usere will input e.g :

Contract StartDay = 10-Oct-08
Contract LastDay = 15-Oct-09
Month = Oct-09

And the result = 15 (Since the employee will spend 15 days in Oct-09)

>> What is the formula or How can I make the third and forth fields (Month + Result) ?

Any ideas .
 
Have a look at the DatePart and DateDiff functions. They're available in both SQL and VB.
 
Hi redneckgeek,

I've got the sum of days in a month as :
DATEDIFF(day, @date, DATEADD(Month, 1, @date))

But I couldn't get the desired result even with DATEPART & DATEDIFF !

Could you show me please ?

Regards,
 
Hi All,

I wanna create a query in vb.net related to SQL 2005 that gives me the number of days the employee spent or will in a specific month depending on the Contract period as follow:

* The usere will input e.g :

Contract StartDay = 10-Oct-08
Contract LastDay = 15-Oct-09
Month = Oct-09

And the result = 15 (Since the employee will spend 15 days in Oct-09)

>> What is the formula or How can I make the third and forth fields (Month + Result) ?

Any ideas .

Need a little more clarification on how you get to 15 days:confused:
I assume you are looking for the difference between Contract StartDay and Contract Lastday but that wouldn't come out to 15.
 

Users who are viewing this thread

Back
Top Bottom