473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

regarding Date function

vp
Hi all,

I have to send a file on 3rd friday of every month. Can you please let
me know how to get the 3rd friday on every month using SQL

Jan 24 '06 #1
5 1285
vp wrote:
Hi all,

I have to send a file on 3rd friday of every month. Can you please let
me know how to get the 3rd friday on every month using SQL


What's the problem? Just find out if its a Friday and if it is test that
the day is between the 15th and the 21st.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Jan 24 '06 #2
vp
I have to create a file using EXPORT and I have to create it on 3rd
friday of everymonth.
i.e if its 3rd friday of any month I will have to create a file.......

Jan 24 '06 #3
vp wrote:
Hi all,

I have to send a file on 3rd friday of every month. Can you please let
me know how to get the 3rd friday on every month using SQL

CREATE FUNCTION ThirdFriday(dt DATE)
RETURNS DATE
CONTAINS SQL DETERMINISTIC NO EXTERNAL ACTION
RETURN dt - (day(dt) - 1) days /* First of the month */
+ CASE dayofweek_iso(dt - (day(dt) - 1) days)
WHEN 1 THEN 18
WHEN 2 THEN 17
WHEN 3 THEN 16
WHEN 4 THEN 15
WHEN 5 THEN 14
WHEN 6 THEN 20
WHEN 7 THEN 19 END DAYS;

VALUES thirdfriday(DATE('2006-01-10'))
=> 01/20/2006

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Jan 24 '06 #4
SELECT dt
, dt + ( 27 - (DAY(dt)+12-DAYOFWEEK(dt))/7*7 - DAYOFWEEK(dt) )
DAYS AS Third_Friday
FROM (SELECT DATE('2006-01-01') + date_incre DAYS AS dt
FROM (VALUES
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10
,11,12,13,14,15,16,17,18,19,20
,21,22,23,24,25,26,27,28,29,30) AS Q(date_incre)
) R
ORDER BY
dt;

Jan 25 '06 #5
If you wish to do it outside of SQL, and you are on a Un*x box, perhaps
you can use cron to run "db2 EXPORT TO FILE...."

B.

Jan 25 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jeremy | last post by:
I am relatively inexperienced with SQL, and I am trying to learn how to analyze some data with it. I have a table with the following information. COMPANY ID , DATE, MarektValue I would like...
16
by: WindAndWaves | last post by:
Hi there I have $initstartdate = date("d-m-Y"); in my code How can I get it to be date() + 1 or 7 for that matter. Because my server is in the US and I am in New Zealand, they are always...
8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
3
by: Aaron | last post by:
Why do my session values return to nothing on post back? I want to click a button and have the row, as in: dataset.table(0).rows(THIS ROW NUMBER IS WHAT I AM TALKING ABOUT), either increment or...
2
by: Dean R. Henderson | last post by:
For an ASP.NET web application, is there a way for one session (with appropriate security authorization) to set a HttpSessionState variable to point to another session and execute the Abandon...
4
by: Benny Van | last post by:
Hi all! I have a question regarding a windows operating system function: I was asked to write a small program for a homework to display the user name and computer name and the system time out to a...
1
by: Dan2kx | last post by:
Hello (again) i have a rather strange problem to tackle i am still doing the holiday database (for those who have helped me before) and now need (which means i have to rethink everything) to...
4
by: bsonline | last post by:
I hv a datetime format like '24/01/2008 15:56:01' . Now I have to select dates from a date range, but input datetime format like 24/1/2008 15:56:01'. I hv written the query like : "select...
5
by: Abhinay | last post by:
Hi there, I am working on server which used thread pool to process each client request by separate dedicated thread. My intention was each thread ( of thread pool ) have its own logger and hence...
0
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...
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.