Click here to Skip to main content
15,946,342 members
Home / Discussions / Database
   

Database

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder16-Jul-09 3:10
cofounderChris Maunder16-Jul-09 3:10 
PinnedHow to get an answer to your question PinPopular
Chris Maunder10-Nov-05 16:30
cofounderChris Maunder10-Nov-05 16:30 
QuestionVb6 and sqlserver 2000 Pin
ahmed ali Apr20217-May-24 17:31
ahmed ali Apr20217-May-24 17:31 
AnswerRe: Vb6 and sqlserver 2000 Pin
Victor Nijegorodov7-May-24 20:07
Victor Nijegorodov7-May-24 20:07 
AnswerRe: Vb6 and sqlserver 2000 Pin
Richard Deeming7-May-24 21:32
mveRichard Deeming7-May-24 21:32 
GeneralRe: Vb6 and sqlserver 2000 Pin
jschell9-May-24 15:35
jschell9-May-24 15:35 
GeneralRe: Vb6 and sqlserver 2000 Pin
Richard Deeming9-May-24 20:58
mveRichard Deeming9-May-24 20:58 
GeneralRe: Vb6 and sqlserver 2000 Pin
jschell11-May-24 9:43
jschell11-May-24 9:43 
GeneralRe: Vb6 and sqlserver 2000 Pin
Victor Nijegorodov11-May-24 21:10
Victor Nijegorodov11-May-24 21:10 
GeneralRe: Vb6 and sqlserver 2000 Pin
Dave Kreskowiak10-May-24 13:31
mveDave Kreskowiak10-May-24 13:31 
GeneralRe: Vb6 and sqlserver 2000 Pin
Richard Deeming12-May-24 21:22
mveRichard Deeming12-May-24 21:22 
GeneralRe: Vb6 and sqlserver 2000 Pin
Dave Kreskowiak13-May-24 3:03
mveDave Kreskowiak13-May-24 3:03 
QuestionSQLite and Firefox Browser 68.0.2 (note: current FFB is now 72.0.2) and what I stand to lose if I update. Pin
RedDk6-May-24 8:56
RedDk6-May-24 8:56 
AnswerRe: SQLite and Firefox Browser 68.0.2 (note: current FFB is now 72.0.2) and what I stand to lose if I update. Pin
Peter_in_27806-May-24 15:18
professionalPeter_in_27806-May-24 15:18 
AnswerRe: SQLite and Firefox Browser 68.0.2 (note: current FFB is now 72.0.2) and what I stand to lose if I update. Pin
Richard Deeming6-May-24 21:44
mveRichard Deeming6-May-24 21:44 
QuestionLooking for a Better Database Solution for Trading Systems Pin
Rene Rose 202120-Apr-24 5:53
Rene Rose 202120-Apr-24 5:53 
AnswerRe: Looking for a Better Database Solution for Trading Systems Pin
Jeremy Falcon20-Apr-24 8:15
professionalJeremy Falcon20-Apr-24 8:15 
AnswerRe: Looking for a Better Database Solution for Trading Systems Pin
RedDk20-Apr-24 8:33
RedDk20-Apr-24 8:33 
AnswerRe: Looking for a Better Database Solution for Trading Systems Pin
jschell23-Apr-24 14:25
jschell23-Apr-24 14:25 
QuestionRun an external program C# from within the Oracle Developer Pin
Member 162354202-Apr-24 10:37
Member 162354202-Apr-24 10:37 
AnswerRe: Run an external program C# from within the Oracle Developer Pin
jschell2-Apr-24 14:18
jschell2-Apr-24 14:18 
QuestionDisplay records based on selected date range in months within same year? Pin
samflex21-Jan-24 9:28
samflex21-Jan-24 9:28 
Greetings,

How do I ensure that the following code only queries records that are submitted between March and May 2024?

If a record has been submitted between the above date range, display 1. Otherwise, display 0.

Currently, we have a code that does this but for entire year.

In the code below, I left the code that performs this check with alias of thisYear.

I left this line of code but commented it out just to show what we have that works except this time, we just want this check to be between March and May 2024.

The code:

CASE WHEN d.dateCreated BETWEEN DATEFROMPARTS(2024, 3, 1) AND DATEFROMPARTS(2024, 5 + 1, 1) THEN 1 ELSE 0 END as thisYear

appears to work sometimes but does not work other times. No errors but wrong results.

That code above, temporarily replaces this line of code below as described above.
--CASE WHEN YEAR(d.dateCreated) = YEAR(getdate()) THEN 1 ELSE 0 END as thisYear


Here is the entire code:

 SELECT e.Name, e.email, e.emptitle, d.dateCreated,
     CASE WHEN YEAR(d.dateSubmitted) < YEAR(getdate()) THEN 1 ELSE 0 END as previousYear,
     --CASE WHEN YEAR(d.dateSubmitted) = YEAR(getdate()) THEN 1 ELSE 0 END as thisYear
 CASE WHEN d.dateSubmitted BETWEEN DATEFROMPARTS(2024, 3, 1) AND DATEFROMPARTS(2024, 5 + 1, 1) THEN 1 ELSE 0 END as thisYear
FROM Employees e
INNER JOIN dateDetails d on e.employeeID = d.employeeID
WHERE e.employeeID = someID


I have also tried this:
CASE WHEN d.dateSubmitted >= DATEFROMPARTS(2024, 3, 1) AND d.dateSubmitted <  DATEFROMPARTS(2024,5 + 1, 1)


Same inconsistent result.

I guess my question is why does this work perfectly:
CASE WHEN YEAR(d.dateSubmitted) = YEAR(getdate()) THEN 1 ELSE 0 END as thisYear


but the date range does not work well?

Thanks in advance for your help.
AnswerRe: Display records based on selected date range in months within same year? Pin
jschell22-Jan-24 5:50
jschell22-Jan-24 5:50 
GeneralRe: Display records based on selected date range in months within same year? Pin
samflex22-Jan-24 8:35
samflex22-Jan-24 8:35 
GeneralRe: Display records based on selected date range in months within same year? Pin
Victor Nijegorodov22-Jan-24 10:10
Victor Nijegorodov22-Jan-24 10:10 

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.