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

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

Posted on 2008-10-08
3
877 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 74

Expert Comment

by:sdstuber
ID: 22675816
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
ID: 22677566
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
ID: 22677582
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

829 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