Solved

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

Posted on 2008-10-08
3
888 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
[X]
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
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
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.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
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…

729 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