1st of the Quarter for yesterday.....

Morning everyone,
I need to write a bit of code that will retrieve the first day of the quarter, based upon yesterday's date (ie 1st of the Q for yesterday would be 01/04/2007). I have managed to achieve this using the following code:
select
case to_char(sysdate-1, 'mm')
when '01' then '01/01/'||to_char(sysdate-1, 'yyyy')
when '02' then '01/01/'||to_char(sysdate-1, 'yyyy')
when '03' then '01/01/'||to_char(sysdate-1, 'yyyy')
when '04' then '01/04/'||to_char(sysdate-1, 'yyyy')
when '05' then '01/04/'||to_char(sysdate-1, 'yyyy')
when '06' then '01/04/'||to_char(sysdate-1, 'yyyy')
when '07' then '01/07/'||to_char(sysdate-1, 'yyyy')
when '08' then '01/07/'||to_char(sysdate-1, 'yyyy')
when '09' then '01/07/'||to_char(sysdate-1, 'yyyy')
when '10' then '01/10/'||to_char(sysdate-1, 'yyyy')
when '11' then '01/10/'||to_char(sysdate-1, 'yyyy')
when '12' then '01/10/'||to_char(sysdate-1, 'yyyy')
end as QTD
from dual;
However, I need to retrieve the result in 'date' format - the above is char. Could anyone kindly point me in the right direction?? (I have tried replacing the to_char's with to_dates, and enclosing the to_char in a to_date - but it either doesnt work, or the format is screwey).
Alternatively - would there be a simplier way to code this?? (I have only been writing SQL for a few months).
Any help would be greatly appreciated.
Kind regards,
P

sql>
select trunc(sysdate-1,'Q') dt
from dual;
DT
01-APR-07                                                                                                                                                                                   

Similar Messages

  • Payment Term for 1st of the Quarter

    Hi,
    Need a new a payment term which should be due on 1st of the quarter. Our Fiscal year yr starts from Jan to Dec.
    If I raise invoice  in Sep 16th,2010, Due date should be 1st of Oct 2010
    If I raise invoice in Oct 20th, 2010, Due date should be 1st Jan 2011.
    How to configure the Payment term ?
    Regards
    Pratap

    Hi Pratap,
    Case I  If I raise invoice in Sep 16th,2010, Due date should be 1st of Oct 2010
    Payment Terms - ZV001
    Day Limit - 16
    Fixed day - 1
    Additional month - 1
    Then once again go for new entry and provide the details as
    Case II - If I raise invoice in Oct 20th, 2010, Due date should be 1st Jan 2011.
    Payment Terms - ZV001
    Day Limit - 31
    Fixed day - 01
    Additional month - 3
    You need to apply enhancement in FI substitution, where program logic update above payment terms based on quarter in the document line item.
    Regards,
    Santosh

  • Accidentally "poof"-ed the "Search for- Yesterday" search category

    I know you can get back application icons after you poof them from the dock, but is there a way to get that little search icon back on the Finder's left-hand pane after you've poofed it?
    Thanks a bunch!

    Actually, it is a Finder preference, and you just turn it back on. With the Finder active (click on the Desktop), go to Finder in the menu bar, select Preferences, click on the Sidebar icon at the top of the Preferences window, down at the bottom put a check mark in front of the Yesterday search.
    Francine
    Francine
    Schwieder

  • No of Days in the quarter

    Hello Experts,
    I need (NDQ) Number of Days in the Quarter-(For the fiscal year K0) as a variable so that I can use it in the formula for the calculated key figure KF1 in the Bex report.
    Wondering what is the best way to do this.
    Is the user exit for the variable with I_Step = 1, the only option with. Appreciate any alternatives or any feedback on this.
    Thanks,
    Sweatha

    Hi Sweatha,
    if you need the number of days related to the quarter choosen by the user (via pop-up), the variable with step 2 is the only thing you have (can) to implement.
    Pay attention: step = 2 !!!
    If you need more infos...
    Hope this helps.
    Bye,
    Roberto

  • I cannot connect to the iTunes Store.  I receive Error Code -1202.  This problem began yesterday.  I have been successfully connecting to the store for months on this PC.  I am running Windows 7 and the Windows Security Center.  Thanks for any help

    TS1368 I cannot connect to the iTunes Store.  I receive Error Code -1202.  This problem began yesterday.  I have been successfully connecting to the store for months on this PC.  I am running Windows 7 and the Windows Security Center.  Thanks for any help.

    Hello alankilner,
    And welcome to Apple Discussions!
    Using Proxy: Yes
    Try temporarily disabling this setting by following the steps outlined in this Apple support document.
    http://support.apple.com/kb/TS1490
    B-rock

  • Purchasing iOS 3.1 Software Update for iPod touch (1st generation) -i have paid for this, but when it goes to the itunes for downloading it says it is downloading but nothing seems to be happeneing. help please!

    Purchasing iOS 3.1 Software Update for iPod touch (1st generation) -i have paid for this, but when it goes to the itunes for downloading it says it is downloading but nothing seems to be happening. help please!

    Hello mixanme,
    Sorry to hear you are not able to update your iPod touch using iTunes.  Thank you for providing all that information about what is going on. I found an tutorial to assist with issues updating an iPod touch:
    Issues updating or restoring iPod touch
    http://www.apple.com/support/ipodtouch/assistant/restore/
    I hope these steps help!
    Best,
    Sheila M.

  • How do I update the iOS for my 1st generation iTouch?

    I am having difficulty updating the iOS for my 1st generation iPod touch. It is currently at 3.1.3. Can anybody tell me if this is possible?

    A 1G iPod Touch cannot be upgraded past iOS 3.1.3. Sorry.
    B-rock

  • As of yesterday, calendar subscribers are no longer getting event alerts. We are not exceeding the limits for number of calendars

    As of yesterday, calendar subscribers are no longer getting event alerts. We are not exceeding the limits for number of calendars, and have not installed new hardware or software. What else could be causing this, and how do I fix it? This is critical!

    The warranty entitles you to complimentary phone support for the first 90 days of ownership.

  • HT1483 I get a message "The Itunes server could not be contacted, check your internet connection" when trying to check for Ipod Nano software updates. I have a 1st generation Nano and haven't updated the software for a while. My internet connection is wor

    I get a message "The Itunes server could not be contacted, check your internet connection" when trying to check for Ipod Nano software updates. I have a 1st generation Nano and haven't updated the software for a while. My internet connection is working. Was thre a change in the internet address for NANO software updates? Do I have to reconfigure something in Itunes to point to the correct address?

    What version of iTunes are you using?  The latest is 10.6.3. In iTunes, choose Help -> About iTunes to check the version number. If it's lower than 10.6.3, download the latest version from here.
    B-rock

  • Good morning a few weeks ago  I send the request for the replacement program of my ipod nano 1st generation and they sent me the shipping box but I did not get the label to go back,  and I can not  return it , i need to you sent me again the box for retu

    Good morning a few weeks ago  I send the request for the replacement program of my ipod nano 1st generation and they sent me the shipping box but I did not get the label to go back,  and I can not  return it , i need to you sent me again the box for return the ipod

    Best thing would be to call Apple up again, and let them what has happened and they'll help you!

  • I've recently installed IOS 7.0.3. With the latest automatic upgrade of First Class yesterday the textfields for loggning in disappears upworth. How can I correct this.

    I've recently installed IOS 7.0.3. on my Ipad4. With the latest automatic upgrade of First Class yesterday the textfields for loggning in disappears upworth. How can I correct this.

    HALF-SOLUTION!!!! (Restoring only, basically.)
    Restore the phone via iCloud.com
    1. Go to iCloud.com , and log in.
    2. If you want a back up, make sure you back it up to itunes now!
    3. Now back to iCloud.com - select the device you want. Press "Erase iPhone" (or iPad, iPod whatever).
    You will go through a few steps. Skip the phone number and leave a message, as it isn't lost. Your phone will be restored. No need for plugging in!
    4. IMPORTANT: Just set it up as usual. Language, country blah. But then you'll get to a step where it says something like "This iPhone was erased with iCloud. Log in with the Apple ID you used to erase it". In this case, my Dad's. So please do that. Later on, the phone will ask for an Apple ID to be used for the phone. I put my own one as I didn't want my dads!!!! Lol....
    5. Plug into iTunes and back-up.
    As for updating, I'm still on 7.0.2,,, it ain't working on my phone or itunes!! :(

  • Ok, so basically my charger fell apart on my MacBook pro(2010) and I didn't have the money for a new charger, I got it in the states too if that's relevant. Basically my laptop will not charge, I bought a new charger yesterday and it's still no-use

    Ok, so basically my charger fell apart on my MacBook pro(2010) and I didn't have the money for a new charger, I got it in the states too if that's relevant. Basically my laptop will not charge, I bought a new charger yesterday and it's still no-use,not charging . No green or orange light coming on on the new charger either.

    It is one of the items that Apple gets criticized at regular intervals. The MagSafe connector is proprietary and unlicensable, so the company has a lock-in on the power options. And as you have now found out, your hijinks trying to avoid buying an expensive new charger may have caused more damage and led to a total no-charge condition.
    If lucky and no physical damage has occurred (there IS a fuse in there somewhere on the circuit boards), maybe resetting the SMC can restore charge functionality, provided there is still enough juice: http://support.apple.com/kb/HT3964

  • How 2 Set the logic for report 2 run 1st of everymonth......

    Hi Experts,
    i ve developd a HR-ABAP report in that Some part of code will Mon-Fri, Excluding Public holidays and sat & sundays...( i.e no public holidays and no sat & sundays)
       and some part of should Run on 1st of everymonth.... but 2 parts of code should be in same report..
    How can set the logic to run the report respective times....
    Thanks in Advance....
    sudeer.

    you can code this but need some good expertise on fm's  , date handling techniques and subroutine call coding.
    1.
    to make the code run only on 1st of every month
    capture the rundate of ur prog .. take value of  sy-datum
    ex.. 01.xx.yyyy
    or date std will be yyyymmdd so check for dd = 01 ..
    so per logic first two chars show that its first of any month in any year ..
    if yes
    execute the logic for the first of every month ..
    endif.
    2.
    where the code needs to be run on mon-fri and not on public holidays / sun / sat ..
    first fetch the day based on date .. like mon or tue or wed .. except sat and sun..
    second check whether if m-t-w-th-fr if any of them is  a holiday or not
    u need to check the date in the calender list like tholi thoc and .. to check whether that is a holiday or not ..
    coming to sat and sundays .. u need to check the day for date using function modules and build the logic ...
    br,
    vijay..

  • Installed the CC updates yesterday. Downloaded pics from my Canon 70D in Camera Raw. Since the updates Bridge no longer recognizes them; advises me to get the latest update, which I have. Both Photoshop CC's recognize the pics, just not Bridge (thanks for

    Installed the CC updates yesterday. Downloaded pics from my Canon 70D in Camera Raw. Since the updates Bridge no longer recognizes them; advises me to get the latest update, which I have. Both Photoshop CC's recognize the pics, just not Bridge (thanks for having Photoshop now show thumbnails of CR pics). Any Ideas on how to fix?

    Thanks for the link Jeff. Couldn't find any links on the Adobe site.
    Even with that link though, I was still left puzzled as it didn't give multiple versions, just a 32 bit and 64 bit version.
    I tried the 64 bit and it didn't work, so I assumed that was what had already been installed in the update.
    Now installed the 32 bit version, and fingers crossed. At least it starts up now!
    Cheers Russell F

  • After instaling the update for OS yesterday (saturday 7.10.2012) my macbook pro will not start. The instaling proses start but stopp after 2-3 minutes. I have started mayby 10 tims know but it stops every time. Help, its just a monts ago my iMac hard fail

    After instaling the update for OS yesterday (saturday 7.10.2012) my macbook pro will not start. The instaling proses start but stopp after 2-3 minutes. I have started mayby 10 tims know but it stops every time. Help, its just a monts ago my iMac hard fail

    Actually it sometimes gets a little further, the display will dim and the pointer will appear and then whoop it will turn off. if i do a verbose start up, it will finish all the steps, the white screen will appear and dim and then it will turn off.

Maybe you are looking for

  • Acrobat Pro XI - Inserting a blank page creates a bookmark

    When I insert a blank page Acrobat automatically creates a bookmark pointing to that blank page. Is there a way to prevent this behavior?

  • How do I sync Safari bookmarks onto iPad?

    I may be missing something (new iPad and also new to Mobil me) but I cannot figure out how to sync my Safari bookmarks onto my iPad. This would include the Safari bar. Can anyone help? Thanks, Ken

  • I would like to install Mountain Lion when it comes out...

    I have a late 2010 MBA 13 with 2GB of RAM and a 128GB SSD running OSX Snow Leopard. I'd like to install Mountain Lion when it comes out. I've heard that I must have OSX Lion first. I've always backed up my Mac using Time Machine to an external HDD, a

  • Powerpoint on a new iMac-- memory issue

    Using 2004 Office/Powerpoint on a new iMac with 8GB RAM...continue to get 'not enough memory' message when trying to make a large Powerpoint file...so far, 200 pp of photos, with 100 to go.  Why?  Solution?

  • Missing hdd password in bios

    Hello everyone, I have Toshiba Portege R705-P25 (pt314u-00u014) equipped with Toshiba hard disk drive MK5065GSX and installed power-on password on that HDD. Password that I know and I can start up computer. Problem is there is no longer any option in