Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2013-01-22
3
502 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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