## days into completed weeks only

 Author Message LoosinMaMind SSCommitted Group: General Forum Members Points: 1686 Visits: 565 Hi how do i easilty convert days into weeks (obviously Days/7 will give me weeks as decimal) Problem i have is I only want to count completed weeks:ie: 20 days is 2.86 weeks. need answer to be 2 and not 3 as i get in SQL.Thanks bitbucket-25253 SSC-Dedicated Group: General Forum Members Points: 35087 Visits: 25280 Is this what you need to do ?`SELECT 2.86 /1 - 2.86 % 1 SELECT 2.16 /1 - 2.16 % 1`Result for both selects is 2.000000Note that the "%" is the modulo operator - check it out in BOL it is a powerful tool to become familiar with. If everything seems to be going well, you have obviously overlooked something. RonPlease help us, help you -before posting a question please read Before posting a performance problem please read LoosinMaMind SSCommitted Group: General Forum Members Points: 1686 Visits: 565 Thanks, sorted the issue now. davidandrews13 Hall of Fame Group: General Forum Members Points: 3849 Visits: 4858 i do: `select FLOOR(2.86)` CapnHector SSCrazy Eights Group: General Forum Members Points: 8259 Visits: 1789 LoosinMaMind (9/10/2012)Hi how do i easilty convert days into weeks (obviously Days/7 will give me weeks as decimal) Problem i have is I only want to count completed weeks:ie: 20 days is 2.86 weeks. need answer to be 2 and not 3 as i get in SQL.Thankswatch your data types. using integers 20/7 = 2 since SQL Server throws away the remainder when performing integer math. if you want to be absolutely certain / more precise / more explicit, i would use float or decimal with FLOOR(). For faster help in answering any problems Please read How to post data/code on a forum to get the best help - Jeff Moden for the best way to ask your question.For performance Issues see how we like them posted here: How to Post Performance Problems - Gail ShawNeed to Split some strings? Jeff Moden's DelimitedSplit8KJeff Moden's Cross tab and Pivots Part 1Jeff Moden's Cross tab and Pivots Part 2 Lynn Pettis SSC Guru Group: General Forum Members Points: 225918 Visits: 40423 LoosinMaMind (9/10/2012)Thanks, sorted the issue now. Proper forum etiquette would have you share your solution with others. It may help someone with a similar issue. Lynn PettisFor better assistance in answering your questions, click hereFor tips to get better help with Performance Problems, click hereFor Running Totals and its variations, click here or when working with partitioned tablesFor more about Tally Tables, click hereFor more about Cross Tabs and Pivots, click here and hereManaging Transaction LogsSQL Musings from the Desert Fountain Valley SQL (My Mirror Blog) Mitesh Oswal SSCommitted Group: General Forum Members Points: 1744 Visits: 653 Please check if this can help you!!!select CAST(20.0/7 AS INT) + CASE WHEN (20%7) > 3 THEN 1 ELSE 0 END Regards,Mitesh OSwal+918698619998