Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-10-08
3
Medium Priority
?
906 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

650 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