I have the following query:
select
a.MyDate,
Sunday = dateadd(dd,((datediff(dd,'17530107',a.MyDate)/7)*7)+7,'17530107')
from
( -- Test Data
select MyDate = convert(datetime,'20100930')
) a
and what I'd like to do is instead of offering a datetime, I have a SQL field that I need to pull from with the date. Can anyone offer me a suggestion on how to do that?
What I see changing is the
select MyDate = [exceptions].exceptiondate.
I tried that though and I get an error:
The column prefix 'exceptions' does not match with a table name or alias name used in the query.
Thank you,
Doug
This -
-
select MyDate = [exceptions].exceptiondate.
-
-
has to be a complete subquery. If your intention is to get it from a table, do a -
-
select MyDate = exceptiondate
-
from exceptions
-
-
or a straight forward: -
-
select
-
exceptiondate,
-
Sunday = dateadd(dd,((datediff(dd,'17530107',exceptiondate)/7)*7)+7,'17530107')
-
from exceptions
-
Good Luck!!!
~~ CK
3 3744 ck9663 2,878
Recognized Expert Specialist
This -
-
select MyDate = [exceptions].exceptiondate.
-
-
has to be a complete subquery. If your intention is to get it from a table, do a -
-
select MyDate = exceptiondate
-
from exceptions
-
-
or a straight forward: -
-
select
-
exceptiondate,
-
Sunday = dateadd(dd,((datediff(dd,'17530107',exceptiondate)/7)*7)+7,'17530107')
-
from exceptions
-
Good Luck!!!
~~ CK
CK,
here's what I went with:
select payrolldate,
Sunday = dateadd(dd, ((datediff(dd, '17530107', payrolldate)/7)*7)+7, '17530107')
from payroll
where payrollran = 'no'
that returns the value that I need back to me.
ck9663 2,878
Recognized Expert Specialist
Yes, the straight forward option....Am glad you made it to work...
Happy Coding!!!
~~ CK
Sign in to post your reply or Sign up for a free account.
Similar topics
by: J. Muenchbourg |
last post by:
Looking thru my resources, I cannot find a simple way of displaying next
sunday's date depending on what todays date is. I'd like to do it
without doing 7 if statements or case select:
...
|
by: Petr Bravenec |
last post by:
I have found that when I use the RETURN NEXT command in recursive function,
not all records are returned. The only records I can obtain from function
are records from the highest level of...
|
by: anshul |
last post by:
Can somebody tell me about state management in asp.net
using Query Strings.
I am just unable to understand this.
Anshul
|
by: CSN |
last post by:
Is it possible to reverse the order of items returned
from a plpgaql function that uses RETURN NEXT? (order
by col isn't what I want)
select * from my_function();
...
|
by: A.M |
last post by:
Hi,
Is there any way to call a WSS web service method by using browser and see
the XML result in browser as well?
I have been told that there is query string syntax for calling...
|
by: Bryan_Cockrell |
last post by:
Hi World,
I am extracting text from an ebcdic header using dd in the cygwin environment (bash/ksh) as below in order to rename the file to something intelligent.
I'm using a specific string...
|
by: khalidbaloch |
last post by:
i want to show on page the messege that say there is currently no item when a mysql query return no record instead of blank page ..
i hope this is not a big issue and will be resolved in first reply...
|
by: =?Utf-8?B?VG9ueSBBLg==?= |
last post by:
I'm trying to develop a parameter query using Query Builder, the database is
Access 2003. I placed a ? in the column to we quered and linked it to a
checkbox on the form. When the user selects an...
|
by: viper888 |
last post by:
Hi there,
How can I automate may database backup using query analyser?
My routine goes this way:
1. Every 5:00pm check Enterprise manager who is currenlty logged on to sql server.
2. If there...
|
by: kkshansid |
last post by:
same query return rows in mysql but not on php page
while($rs = mysql_fetch_array($sql2))
{
$town=$rs;
$q="select * from institute where address like '%".$town."%'";//this query
//echo $town;...
|
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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |