Is there a way to find Weekend date for a given date using a DB2
query? I see that there are scalar functions such as DAY, DAYOFMONTH,
DAYOFWEEK,etc are available...but couldn't find one to get a weekend
date for any given date. Any information is appreciated.
Thanks,
Aditya. 7 13459
Not sure how you define weekenddate, but thsi litle function will give
you the last saturday or today if today is saturday:
create function saturday(d date)
returns date
contains sql deterministic no external action
return case when dayofweek(d)<7 then d - dayofweek(d) days else d end
Enjoys
Serge
I think DAYOFWEEK function will help you, pls ref. to SQL Reference 1.
"AdityaK" <ad*******@gmai l.com> ????
news:63******** *************** ***@posting.goo gle.com... Is there a way to find Weekend date for a given date using a DB2 query? I see that there are scalar functions such as DAY, DAYOFMONTH, DAYOFWEEK,etc are available...but couldn't find one to get a weekend date for any given date. Any information is appreciated.
Thanks, Aditya.
my test:
db2 create table zd( time timestamp)
db2 insert into zd (values current timestamp)
db2 select date(time)+(7-dayofweek(time) ) days from zd
pls try.
"AdityaK" <ad*******@gmai l.com> ????
news:63******** *************** ***@posting.goo gle.com... Is there a way to find Weekend date for a given date using a DB2 query? I see that there are scalar functions such as DAY, DAYOFMONTH, DAYOFWEEK,etc are available...but couldn't find one to get a weekend date for any given date. Any information is appreciated.
Thanks, Aditya.
AdityaK wrote: Is there a way to find Weekend date for a given date using a DB2 query? I see that there are scalar functions such as DAY, DAYOFMONTH, DAYOFWEEK,etc are available...but couldn't find one to get a weekend date for any given date. Any information is appreciated.
Do you want to have the Saturday or Sunday? If it is the Sunday, which one
do you want to get? (Note the convention in the US is often that the week
starts on Sunday, whereas it starts on Monday in Europe.)
--
Knut Stolze
Information Integration
IBM Germany / University of Jena
How about this?
------------------------------ Commands Entered ------------------------------
SELECT givendate
, givendate + (7-DayOfWeek_ISO(g ivendate)) DAYS AS Weekend
FROM (VALUES Current Date) AS R(givendate)
;
------------------------------------------------------------------------------
GIVENDATE WEEKEND
---------- ----------
2004-10-27 2004-10-31
1 record(s) selected. to*****@jp.ibm. com (Tokunaga T.) wrote in message news:<81******* *************** ****@posting.go ogle.com>... How about this? ------------------------------ Commands Entered ------------------------------ SELECT givendate , givendate + (7-DayOfWeek_ISO(g ivendate)) DAYS AS Weekend FROM (VALUES Current Date) AS R(givendate) ; ------------------------------------------------------------------------------
GIVENDATE WEEKEND ---------- ---------- 2004-10-27 2004-10-31
1 record(s) selected.
Thanks a lot everybody for your response...
I was trying out this query to get SATURDAY's date in that week.
"select column1,column2 ,rcpt_date,week enddate(rcpt_da te) from ATABLE
where conditions;"
I tried the query in previous response but am getting SQL error:
'SQLCODE = -199, ERROR: ILLEGAL USE OF KEYWORD CURRENT, TOKEN FULL
LEFT INNER RIGHT WAS EXPECTED'
Thanks,
Aditya K to*****@jp.ibm. com (Tokunaga T.) wrote in message news:<81******* *************** ****@posting.go ogle.com>... How about this? ------------------------------ Commands Entered ------------------------------ SELECT givendate , givendate + (7-DayOfWeek_ISO(g ivendate)) DAYS AS Weekend FROM (VALUES Current Date) AS R(givendate) ; ------------------------------------------------------------------------------
GIVENDATE WEEKEND ---------- ---------- 2004-10-27 2004-10-31
1 record(s) selected.
Thanks a lot... I was able to get Weekend date (Saturday's date) using
above query.... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Barry Warsaw |
last post by:
The current mail.python.org machine has had many problems over the last
few weeks, and it's time to move. Also, we have a deadline of
06-Jul-2004 before ZopeCorp and Baymountain decommission the machine and
pull the plug on it.
Fortunately, Thomas Wouters and the fine folks at XS4ALL have donated a
machine, and your friendly neighborhood volunteer postmasters have been
working round the clock (okay, in 3-minute chunks while we recompile...
|
by: AdityaK |
last post by:
Is there anyway I can get weekend date for a given date using DB2
query? I couldn't find any DB2 function that can be used to do so.
Thanks,
Aditya
|
by: Joey Martin |
last post by:
I have a sql database and ASP pages.
How do I find out the DATES of THIS WEEKEND (fri-sun).
If today is Tuesday, I want to show information posted for THIS WEEKEND.
My table has a field called THEDATE which is what we need to search and
in the format MM/DD/YYYY.
Thanks!
|
by: darnnnel |
last post by:
Hey guys, i have this code:
SELECT *
FROM QueryCases
WHERE Weekday(QueryCases.StartDate) In ('1','7') AND QueryCases.Completed = False
ORDER BY QueryCases.StartDate;
the WHERE Weekday(QueryCases.StartDate) In ('1','7') returns any weekend records, how do i set criteria to only show weekend records for this coming weekend. Thanks in advance
|
by: ysoussov |
last post by:
Hey does anyone know of an easy script to use to figure out whether
the current date is a weekend or not, i currently have a script that
returns the current date and time. Also it would be great if it could
take into account holidays.
| |
by: Paul W Smith |
last post by:
I have written a hit counter, which I believe counts the times my page is
hit by a user for each unique session by the user.
The relevant part of my code is below:
If IsEmpty(Session("TotalCount")) Then
' Increment or reset the count
If Weekday(Date(),vbSunday) = 1 And dtDate <Date then
|
by: buddyr |
last post by:
Hello,
I have a form.
When a user enters item number Date shipped field is filled with current date.
TurnAroundTime is a number field to add the number of days to Date shipped.
DatOut is an unbound textbox on form.
I want DateOut filled with Date shipped + TurnAroundTime.
The turn around time number is static and assigned to Item numbers.
I have tried creating a module and a call in the main form and subforms.
|
by: Mike |
last post by:
I have a routine that's calculating business days but its not counting the
weekend days that are between the start date and end date. If my start date
is 9/26/08 and my end date is 10/01/08, I should see 4 business days and 2
weekend days.
How can I get that result? I'm getting 4 business days but its not counting
the weekend days?
|
by: welshboi |
last post by:
Hi all, long time reader, first time poster :D
I've got a page i've put together in javascript, and one of the fields takes the date (in dd/mm/yyyy) format.
What I'm trying to do, is if a user enters a date which falls on a weekend (eg, 07/11/2009), then to throw an error.
I've had a play, but i'm very confused and couldn't get anything to work :(
Fingers crossed someone can help :D
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |