|
-
Nov 7th, 2005, 11:18 AM
#1
Thread Starter
Fanatic Member
Round up date calc
Guys,
How do I round this UP to the actual number of weeks ?
datediff(d,c.startdate,c.enddate)/7 as ContractPeriod
Example, 10/10/05 - 15/06/07 is 87.57 weeks, I need to show this as 88.
Thanks
Bob
"I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
-
Nov 7th, 2005, 11:28 AM
#2
Re: Round up date calc
Try
VB Code:
Private Sub Command1_Click()
MsgBox Round(87.57)
End Sub
-
Nov 7th, 2005, 11:51 AM
#3
Thread Starter
Fanatic Member
Re: Round up date calc
Sorry, my mistake, I meant in my SQL view....
ALTER view vw_Rpt_ContractorReport
AS
SELECT cr.*,
c.ID AS Contract_ID,
c.name as Contract_Name,
c.startdate as ContractStartDate,
c.enddate as ContractEndDate,
datediff(d,c.startdate,c.enddate)/7 as ContractPeriod
FROM ContractorReport cr
Join Contract c on c.id = cr.Contract
"I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
-
Nov 7th, 2005, 02:00 PM
#4
Re: Round up date calc
As the functions available vary significantly by DBMS, we will need to know which database system you are using.
-
Nov 9th, 2005, 08:29 AM
#5
Thread Starter
Fanatic Member
Re: Round up date calc
Thanks for the response Si,
I am using SQL Server 2000
Bob
"I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings
-
Nov 9th, 2005, 11:28 AM
#6
Re: Round up date calc
Have you tried using ww as datepart parameter for the DATEDIFF function?
Code:
DATEDIFF(ww,c.startdate,c.enddate)
-
Nov 9th, 2005, 01:11 PM
#7
Re: Round up date calc
Good point, but I don't think that would round up.
I've just remembered a little trick tho, how about this:
(datediff(d,c.startdate,c.enddate)+6)/7 as ContractPeriod
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|