Solved

DB2 date function for Thurs, Fri, Sat of every week

Posted on 2013-01-22
3
504 Views
Last Modified: 2013-01-31
I'm creating a dynamic report. I need a date function for items that may expire on Thurs or Fri or Sat of every week that the report is run.
How do would I write such a date function?

Thank you.
0
Comment
Question by:saved4use
3 Comments
 
LVL 37

Expert Comment

by:momi_sabag
ID: 38808107
what exactly do you want the function to do? it is not clear from your description
0
 

Author Comment

by:saved4use
ID: 38808150
Reflect items that expire on Thurs, or Fri or Sat of every week. *I need a DB2 date function, for example, 'CURRENT _DATE + 3 days'
0
 
LVL 45

Accepted Solution

by:
Kent Olsen earned 500 total points
ID: 38808313
Hi Saved,

That's somewhat ambiguous, but with just a bit more information the query is easy to write.

SELECT *
FROM {mytable}
WHERE dayofweek (expiration_date > 4)               -- select only thurday, friday, saturday
  AND current_date + 6 days <= expiration_date   -- and within the next 7 days
  AND expiration_date >= current_date                  -- and in the future (or today)

That's a pretty good start.  It's easy to adjust as you need it.


Good Luck,
Kent
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question