Solved

How to get dates for fiscal quarters for report generation based on year

Posted on 2008-10-08
3
857 Views
Last Modified: 2013-12-18
I am writing a store procedure , which generates reports for every fiscal quarter.

I am passing YEAR as input argument -- input_arg_year , and we have start and end ( day and months for fiscal quarters as constants)

now my question is how can i append start and end dates with the year( input_arg_year)  to form a valid date. which can be used further in my store proc, for report generation.
 Ex: Jan1st is quarter start date and input arg is 2008
       date = 01012008 .......something like this

let me know, how can i append and convert the string into a valid date.

give an example , so that can understand easily , i am a naive developer ( basically asp.net developer)
0
Comment
Question by:Swetha_aJaX
3 Comments
 
LVL 73

Expert Comment

by:sdstuber
Comment Utility
given  a string '01012008'  that could be interpreted as ddmmyyyy  or mmddyyyy


so, depending on which way you intend your data to be structured you use the to_date function


for example....  

select to_date('01012008','mmddyyyy') date_format_1,  to_date('01012008','ddmmyyyy') date_format_2 from dual
0
 

Author Comment

by:Swetha_aJaX
Comment Utility
can you give some example of how to append the input argument with the date.

i tried this way -- qrtr_start_dt := '0101' + input_arg_date;

is the above interpretation correct?
0
 
LVL 9

Accepted Solution

by:
jamesgu earned 500 total points
Comment Utility
to append start and end dates with the year( input_arg_year) , use ||
to convert a string to date, use sdstuber' s example

a quick example

declare
start_date varchar(10) := '0101';
input_arg_year varchar(10) := '2008';
startDate date;
begin
select to_date(start_date || input_arg_year, 'mmddyyyy') into startDate from dual;
--dbms_output.put_line(startDate);

end;
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Oracle Syntax 8 38
How to query date ranges with SQL 6 22
Clone Oracle 12c Database 5 24
PL/SQL Search for multiple strings 5 20
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now