I'm trying to add my case statment inside the condition but I think I'm not doing this right. I want to run a list of orders based on current date.
Let say if current date is monday I want to run the added orders made from friday 3pm.
And if current date is tuesday then I want to run the orders added yesterday from 3pm.
Having this condition all I have to do is to play with the getdate and dateadd. Now I'm having problems in my case condition and it looks like this. - select * from orders
-
where
-
CASE WHEN GETDATE()=DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) --to get Monday
-
THEN CONVERT(VARCHAR(10), DATEADD(D-3,GETDATE()), 121)+' 14:59:059.059' AND CONVERT(VARCHAR(10), GETDATE(), 121)+' 15:00:000.000'
-
CASE WHEN GETDATE()<>DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0)
-
THEN CONVERT(VARCHAR(10), DATEADD(D,-1,GETDATE()), 121)+' 14:59:059.059' AND CONVERT(VARCHAR(10), GETDATE(), 121)+' 15:00:000.000'
-
END
=ORDER_CREATETIMESTAMP
1 1831
It should be along the lines of this - CASE DATEPART(WEEKDAY, GETDATE())
-
WHEN 2 THEN DATEADD(D, -3, GETDATE())
-
ELSE DATEADD(D, -1, GETDATE()) END
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Largo SQL Tools |
last post by:
Can anyone tell me if it's possible to use a Case statement in a Where
clause, and if so, the proper syntax?
J.R.
Largo SQL Tools
The Finest Collection of SQL Tools Available...
|
by: mirth |
last post by:
I would like to update a decimal column in a temporary table based on
a set of Glcodes from another table. I search for a set of codes and
then want to sum the value for each row matching the...
|
by: Bryan |
last post by:
I am executing a case statement list below,
USE Northwind
SELECT
MONTH(OrderDate) AS OrderMonth,
SUM(CASE YEAR(OrderDate)
WHEN 1996 THEN 1
ELSE 0
END) AS c1996,
|
by: Chad Richardson |
last post by:
I've always been mistified why you can't use a column alias in the group by
clause (i.e. you have to re-iterate the entire expression in the group by
clause after having already done it once in the...
|
by: Mark Mullins |
last post by:
have code below:
Function ClassColl(strClass As Variant, strColl As Variant) As String
' Comments :
' Parameters : strClass
' strColl
' Returns : String Description
'...
|
by: paulmac106 |
last post by:
If you could help me with my syntax i would really appreciate
it. I'm trying to change the where clause on the fly, but it's
giving me a syntax error.
Hopefully from what I have below you can...
|
by: priyanka2203 |
last post by:
Hi guys,
I have a doubt regarding the CASE statement. It might sound silly, but me being new to DB2, it is kind of a genuine doubt. Try helping me with this..
When we use a case statement...
|
by: shipmen |
last post by:
Hi all !
This is my first post here. I am totally new to db2 and last night I faced with this problem:
I want to order my query results by different columns in ORDER BY clause using CASE...
|
by: pintu |
last post by:
Hi Friends,
I want to use "in" clause in case statement as shown below.
e.g
select * from employee
where empid in
case i_desgn
when 'HR' then (1,2,3,4,5)
when 'MD' then 1
else 7
end
|
by: Napsterr |
last post by:
Following is the Code I am trying
Declare @Day Int
Set @Day=1
Select
Mobile,
Contact As Name,
InTimeDay1
From uvw_UserDetails
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |