Click here to Skip to main content
15,885,366 members
Home / Discussions / Database
   

Database

 
AnswerRe: Need to load bulk Data with some conditions Pin
Mycroft Holmes27-Jun-17 19:26
professionalMycroft Holmes27-Jun-17 19:26 
GeneralRe: Need to load bulk Data with some conditions Pin
indian14328-Jun-17 8:14
indian14328-Jun-17 8:14 
GeneralRe: Need to load bulk Data with some conditions Pin
indian14312-Jul-17 7:41
indian14312-Jul-17 7:41 
QuestionORDER BY issue with Interbase XE SQL Server Pin
User 1106097925-Jun-17 2:32
User 1106097925-Jun-17 2:32 
QuestionRe: ORDER BY issue with Interbase XE SQL Server Pin
Eddy Vluggen25-Jun-17 3:06
professionalEddy Vluggen25-Jun-17 3:06 
GeneralRe: ORDER BY issue with Interbase XE SQL Server Pin
User 1106097925-Jun-17 3:24
User 1106097925-Jun-17 3:24 
GeneralRe: ORDER BY issue with Interbase XE SQL Server Pin
Eddy Vluggen25-Jun-17 3:40
professionalEddy Vluggen25-Jun-17 3:40 
QuestionSQL: Split calendar week between a given two date time Pin
Number0523-Jun-17 3:29
Number0523-Jun-17 3:29 
Hi,

I want to list a calendar weeks which falls between two given dates.

Ex: StartDate :2016-01-04 02:19:45.000 and EndDate : 2016-08-31 07:57:37.000

I want output as follows :

StartDate EndDate
------------------------------------------------------------------
2016-01-04 02:19:45.000 2016-01-10 00:00:00.000
2016-01-11 00:00:00.000 2016-01-17 00:00:00.000
2016-01-18 00:00:00.000 2016-01-24 00:00:00.000
2016-01-25 00:00:00.000 2016-01-31 00:00:00.000
2016-02-01 00:00:00.000 2016-02-07 00:00:00.000
2016-02-08 00:00:00.000 2016-02-14 00:00:00.000
2016-02-15 00:00:00.000 2016-02-21 00:00:00.000
2016-02-22 00:00:00.000 2016-02-28 00:00:00.000
. . . .
. . . .
. . . .
. . . .
. . . .
2016-08-01 00:00:00.000 2016-08-07 00:00:00.000
2016-08-08 00:00:00.000 2016-08-14 00:00:00.000
2016-08-15 00:00:00.000 2016-08-21 00:00:00.000
2016-08-22 00:00:00.000 2016-08-28 00:00:00.000
2016-08-29 00:00:00.000 2016-09-04 07:57:37.000

I have tried the following code but did not get the accurate output.
------------------------------------------------------------------------------
WITH CW as (
SELECT --@StartTime STARTDATE
-- DATEADD(WEEK, DATEDIFF(WEEK, 0, @StartTime), 0) FirstDayOfWeek
DATEADD(WK, DATEDIFF(WK, 0, @StartTime), 0) STARTDATE
, DATEADD(WK, DATEDIFF(WK, 0, @StartTime), 6) ENDDATE

UNION ALL
SELECT DATEADD(WW, 1, STARTDATE)
, DATEADD(WW, 1, ENDDATE)

FROM CW
WHERE DATEADD(WW, 1, STARTDATE) <= @EndTime )

Thanks in advance....
AnswerRe: SQL: Split calendar week between a given two date time Pin
Richard Deeming23-Jun-17 6:18
mveRichard Deeming23-Jun-17 6:18 
GeneralRe: SQL: Split calendar week between a given two date time Pin
Number0526-Jun-17 22:06
Number0526-Jun-17 22:06 
GeneralRe: SQL: Split calendar week between a given two date time Pin
Number0527-Jun-17 5:10
Number0527-Jun-17 5:10 
GeneralRe: SQL: Split calendar week between a given two date time Pin
Richard Deeming27-Jun-17 5:37
mveRichard Deeming27-Jun-17 5:37 
GeneralRe: SQL: Split calendar week between a given two date time Pin
Number0528-Jun-17 4:30
Number0528-Jun-17 4:30 
GeneralRe: SQL: Split calendar week between a given two date time Pin
Richard Deeming28-Jun-17 7:46
mveRichard Deeming28-Jun-17 7:46 
GeneralRe: SQL: Split calendar week between a given two date time Pin
Number053-Jul-17 1:41
Number053-Jul-17 1:41 
QuestionBasic Entity Framework Question Pin
Kevin Marois21-Jun-17 7:54
professionalKevin Marois21-Jun-17 7:54 
AnswerRe: Basic Entity Framework Question Pin
mike1402125-Jun-17 21:24
mike1402125-Jun-17 21:24 
QuestionPDO Return Single Result, How To Return Different Record From 1 Column Multiple Rows Pin
Member 1326709919-Jun-17 1:21
Member 1326709919-Jun-17 1:21 
Questionsingle DataSet having multiple DataTables from multiple databases Pin
Hailu Worku Obsse14-Jun-17 21:24
professionalHailu Worku Obsse14-Jun-17 21:24 
AnswerRe: single DataSet having multiple DataTables from multiple databases Pin
Richard Deeming15-Jun-17 1:51
mveRichard Deeming15-Jun-17 1:51 
GeneralRe: single DataSet having multiple DataTables from multiple databases Pin
Hailu Worku Obsse16-Jun-17 2:17
professionalHailu Worku Obsse16-Jun-17 2:17 
GeneralRe: single DataSet having multiple DataTables from multiple databases Pin
Richard Deeming16-Jun-17 2:22
mveRichard Deeming16-Jun-17 2:22 
AnswerRe: single DataSet having multiple DataTables from multiple databases Pin
Mycroft Holmes15-Jun-17 13:16
professionalMycroft Holmes15-Jun-17 13:16 
GeneralRe: single DataSet having multiple DataTables from multiple databases Pin
Eddy Vluggen16-Jun-17 3:18
professionalEddy Vluggen16-Jun-17 3:18 
QuestionError in SSIS Connection says (Test connection failed because of an error in initializing provider. ORA-12541: TNS:no listener) Pin
indian1437-Jun-17 13:12
indian1437-Jun-17 13:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.