Click here to Skip to main content
16,005,121 members
Home / Discussions / Database
   

Database

 
Questionchange db from sql server 2000 to sqlserver 2005 Pin
Jes M George16-Apr-07 20:21
Jes M George16-Apr-07 20:21 
AnswerRe: change db from sql server 2000 to sqlserver 2005 Pin
Krish - KP16-Apr-07 20:46
Krish - KP16-Apr-07 20:46 
AnswerRe: change db from sql server 2000 to sqlserver 2005 Pin
Arun.Immanuel20-Apr-07 18:30
Arun.Immanuel20-Apr-07 18:30 
QuestionGet all Sundays between 2 dates in sql Pin
cst_cfit16-Apr-07 19:58
cst_cfit16-Apr-07 19:58 
AnswerRe: Get all Sundays between 2 dates in sql Pin
vivek-g16-Apr-07 20:28
vivek-g16-Apr-07 20:28 
GeneralRe: Get all Sundays between 2 dates in sql Pin
cst_cfit17-Apr-07 23:32
cst_cfit17-Apr-07 23:32 
AnswerRe: Get all Sundays between 2 dates in sql Pin
gauthee16-Apr-07 20:28
gauthee16-Apr-07 20:28 
AnswerRe: Get all Sundays between 2 dates in sql Pin
DQNOK17-Apr-07 4:16
professionalDQNOK17-Apr-07 4:16 
I'm going to say a bunch of stuff here that ASSUMES SQL Server uses the same date system that Microsoft Offices uses. If that's wrong, then what I say here won't apply.

Microsoft Office uses date serial number zero to (sort of) represent Saturday, Dec 30, 1899 (actually, their system is broken below serial number 61 because they assume the year 1900 was a leap year, which it was not -- but that doesn't affect this discussion). Thus, the date serial number modulo 7 gives you the day of the week, counting Sunday as day #1. Taking the interval between two dates, and dividing by 7 gets the number of weeks (and most weeks have one Sunday), then you need to correct for the beginning and end dates in case you get a fraction of a week, or the beginning or end dates are Sunday.

numSundays( date1, date2 )
{
dayOfWeek1 = MOD(date1,7)
dayOfWeek2 = MOD(date2,7)
numSundays = (date2-date1)/7
If(dayOfWeek2 < dayOfWeek1) numSundays++
ElseIf(dayOfWeek2=1 OR dayOfWeek1=1) numSundays++
}

This should give you the number of Sundays INCLUSIVE (includes both start and end dates). BUT, like I said earlier: won't work if SQL Server doesn't use the same dating system as MS Office.

Hope this helps.
GeneralRe: Get all Sundays between 2 dates in sql Pin
cst_cfit17-Apr-07 23:32
cst_cfit17-Apr-07 23:32 
AnswerRe: Get all Sundays between 2 dates in sql [modified] Pin
DQNOK17-Apr-07 7:58
professionalDQNOK17-Apr-07 7:58 
GeneralRe: Get all Sundays between 2 dates in sql Pin
cst_cfit17-Apr-07 23:30
cst_cfit17-Apr-07 23:30 
Questionretrieving the highest IDENTITY number in a table:sqlserv05? Pin
giddy_guitarist16-Apr-07 10:21
giddy_guitarist16-Apr-07 10:21 
AnswerRe: retrieving the highest IDENTITY number in a table:sqlserv05? Pin
Mark J. Miller16-Apr-07 12:20
Mark J. Miller16-Apr-07 12:20 
GeneralRe: retrieving the highest IDENTITY number in a table:sqlserv05? Pin
giddy_guitarist17-Apr-07 9:48
giddy_guitarist17-Apr-07 9:48 
GeneralRe: retrieving the highest IDENTITY number in a table:sqlserv05? [modified] Pin
giddy_guitarist18-Apr-07 4:09
giddy_guitarist18-Apr-07 4:09 
QuestionVB.NET accessing SQL Server 2005 Pin
Marcus J. Smith16-Apr-07 9:43
professionalMarcus J. Smith16-Apr-07 9:43 
AnswerRe: VB.NET accessing SQL Server 2005 Pin
Colin Angus Mackay16-Apr-07 11:24
Colin Angus Mackay16-Apr-07 11:24 
QuestionProblem creating jobs in SQLServer 2005 Pin
allende16-Apr-07 8:19
allende16-Apr-07 8:19 
QuestionCase insensitive order by Pin
ATCsharp16-Apr-07 6:29
ATCsharp16-Apr-07 6:29 
AnswerRe: Case insensitive order by Pin
andyharman16-Apr-07 7:11
professionalandyharman16-Apr-07 7:11 
QuestionCLOB Convert to String Pin
ytubis16-Apr-07 4:57
ytubis16-Apr-07 4:57 
AnswerRe: CLOB Convert to String Pin
Krish - KP16-Apr-07 21:36
Krish - KP16-Apr-07 21:36 
QuestionHow do I protect Access database (MDB file)? Pin
testmail_12316-Apr-07 2:44
testmail_12316-Apr-07 2:44 
AnswerRe: How do I protect Access database (MDB file)? Pin
Dave Kreskowiak16-Apr-07 4:18
mveDave Kreskowiak16-Apr-07 4:18 
GeneralRe: How do I protect Access database (MDB file)? Pin
testmail_12317-Apr-07 1:06
testmail_12317-Apr-07 1:06 

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.