How to find interval in days,week or days month or days

I have to find the total no of month, days or month, weeks or weeks days or only days on the basis of interval between start and end date which user gives the input.

Like if the interval between two dates is not more than 30 than output should be only in days`

For example- StartDate - 1 July EndDate-24 July

%|-110116387_1|% Day 1 July 24 July

Interval is more than 30 days but less than 90 Days` than output should only in days and weeks and my week start from Monday and ends on Sunday

For example- StartDate - 1 July 2015 EndDate-23 September 2015

 Time_Type                      StartDate                              EndDate
    Day                          1-07-2015                            5-07-2015
   Week                         Week2(july)                       Week3(September)
    Day                          21-09-2015                           23-09-2015


Interval is more than 90 Days than output should be in days and months

For example- StartDate – 22 April 2015 EndDate-8 December 2015

 Time_Type                    StartDate                                EndDate
    Day                       22-04-2015                             30-04-2015
   Week                        May2015                              November 2015
    Day                       01-12-2015                              08-12-2015

Here the weeks can be the no of week by year wise like week2 (July) would be 26 week.This is needed in a project and its urgent also please do help me!!! Thank you!

more ▼

asked Oct 08, 2015 at 06:49 AM in Default

avatar image

1 1 3

What have you tried so far?

Oct 08, 2015 at 07:55 AM erlokeshsharma08

I have used datediff, dateadd but problem is that I have to make a entry only when there is whole month or week. IF the start day is tuesday we will go to we will go to the first monday which is on or after start date then from there to sunday on or before end date...I can't solve this part

Oct 08, 2015 at 08:03 AM adishri22



SELECT DATENAME(MONTH,GETDATE()) + ' ' + DATENAME(YEAR,GETDATE()) this is I have tried so far...

Oct 09, 2015 at 08:15 AM adishri22
(comments are locked)
10|1200 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Oct 08, 2015 at 06:49 AM

Seen: 133 times

Last Updated: Oct 09, 2015 at 08:15 AM

Copyright 2018 Redgate Software. Privacy Policy