How to get same day of a month in every year in the DB ( To update a flag )
Hi,
I am trying to formulate an update query for a flag table in our database which contains dates, and flag columns. Currently the system have dates for the next ten years. The flags are updated with values 0 or 1 if a particular date falls under the required criteria.
I need to update flag column for the same day of the month in every year. e.g. 2nd Sunday of October. The value should be updated to all years in the table. Currently I am using the following query to update the current year.
UPDATE FILTERCALENDAR SET YEAR_WINDOW=1 WHERE c_date = NEXT_DAY( TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1)*7;
and for next year Like
UPDATE FILTERCALENDAR SET YEAR_WINDOW=1 WHERE c_date = add_months(NEXT_DAY( TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1)*7,+12)-1;
This is not an excellent way to do it as it does not take care of leap years and it does not scan and update values in the whole table for all years correctly.
Can any one help me to resolve this please.
Hi,
user10903866 wrote:
Hi,
I am trying to formulate an update query for a flag table in our database which contains dates, and flag columns. Currently the system have dates for the next ten years. The flags are updated with values 0 or 1 if a particular date falls under the required criteria.
I need to update flag column for the same day of the month in every year. e.g. 2nd Sunday of October. The value should be updated to all years in the table. Currently I am using the following query to update the current year.
UPDATE FILTERCALENDAR SET YEAR_WINDOW=1 WHERE c_date = NEXT_DAY( TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1)*7;That's the 2nd Sunday after October 1; the 2nd Sunday of October is the 2nd Sunday after September 30, so you need to subtract 1 more day before calling NEXT_DAY.
I'd do it this way:
WHERE c_date = NEXT_DAY ( TO_DATE ( '01-OCT-2013', 'DD-MON-YYYY') - 8
, 'SUNDAY'
) + (7 * 2) -- Last number is week numberRemember, calling NEXT_DAY like this depends on your NLS_DATE_LANGUAGE.
and for next year Like
UPDATE FILTERCALENDAR SET YEAR_WINDOW=1 WHERE c_date = add_months(NEXT_DAY( TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1)*7,+12)-1;If you want the 2nd Sunday in October, 2014, then take the previous expression, and just change 2013 to 2014:
WHERE c_date = NEXT_DAY ( TO_DATE ( '01-OCT-2014' -- or any month and year you want
, 'DD-MON-YYYY'
) - 8
, 'SUNDAY'
) + (7 * 2) -- Last number is week number
This is not an excellent way to do it as it does not take care of leap years and it does not scan and update values in the whole table for all years correctly.
Can any one help me to resolve this please.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
Explain, using specific examples, how you get those results from that data.
See the forum FAQ {message:id=9360002}
Similar Messages
-
How to get last day of prev month?
SELECT to_char(SYSDATE, 'MM') -1, last_day(sysdate)
FROM DUAL;
If current month is April, How to get the last day of March? Thanks.SQL> select sysdate, trunc(sysdate, 'mm') - 1 from dual ;
SYSDATE TRUNC(SYSDA
06-APR-2004 31-MAR-2004
1 row selected.
SQL> -
How to get last day of a month
using pl/sql
What i need is that all members whose birthdate is in the curren month will be included as having had their birthdate regardless of the date of the month. The code i have is:
Select me607.subscriber_id
me607.mbr_dob,
** trunc(months_between (*end of current month*,me607.mbr_dob) / 12) as age
from odw.mbr607_member_expanded me607
The asterixed line is what I need to change. If I put the end of the current month (where I put 'end of current month') then all those whose birthday month is in Feb will show as having had their birthdate. So if run today, folks whose birthdate is 26-feb-2005 will show an age of 5.
When grabbing the last day of the month using visual basic I just use the first day of the subsequent month minus 1. Any assistance is appreciated..Hi,
This does what you requested:
Select me607.subscriber_id, -- Don't you need a comma here?
me607.mbr_dob,
ROUND ( MONTHS_BETWEEN ( SYSDATE
, me607.mbr_dob
/ 12
from odw.mbr607_member_expanded me607
WHERE TO_CHAR (me607.mbr_dob, 'MONTH') =
TO_CHAR (SYSDATE, 'MONTH')
;If this is run sometime in February, 2010, and mbr_dob is sometime in Febrary, 2005, then the result of MONTHS_BETWEEN will be between 59 and 61. When we divide by 12 convert that to years, that difference of up to one month becomes so small that it will be lost in the rounding.
If this isn't exactly what you need, tthen post a little sample data (CREATE TABLE and INSERT statements) and the results you want from that data.
Edited by: Frank Kulash on Feb 17, 2010 1:32 PM
Added explanation. -
I disabled my iPhone 4 and while doing a restore via iTunes, it is downloading and timing out so the download is not completing. any idea how to get past that? I have tried many times and the same error keeps happening.
You need to force the phone into recovery mode, as described here, & restore it:
http://support.apple.com/kb/ht1808
Sorry, you've already lost all data on your phone. -
How to arrive same day two difference prices for same material/customer
how to arrive same day two difference prices for same material/customer.pls give the solution
thanks in advance
Aravinthan.KHi
This is possible through some careful customization
In your condition table you need to bring the field PRICE LIST
That is customer/ Material/ Price list
That is customer ABCD / Material X / Price list 01---Price is Rs 10
That is customer ABCD / Material X / Price list 02---Price is Rs 20
The condition records to be maintained like this
So same material and same customer with price list 01 price is Rs 10 and with price list 02 price is Rs 20
Now in sales order you will find price list field in item details SALES B tab
Through incompletion log you can make this field as an mandatory field
Now in sales order same material and same customer according to the price lists different price is picked
In img-sd-basic functions-Maintain Price-Relevant Master Data Fields--here you can define different price lists
Regards
Raja -
How to get same order of appearance of photos in Iphoto album and album shown to IOS devices after sharing?
Hello Leonie!
I use Iphoto sharing with my family on their ios devises. And it works.
The only problem is that, now, I try to organize the photos in a meaningful way (not chronologically) before Iphoto Sharing (Icloud)
But on the ios devices the photos is arranged chronologically.
Is there a solution?
MBP 2009
Iphoto 9.5.1
IPAD 3
7.1.1
best regards Joakim -
Anyone know how I get charged a late this month?
anyone know how I get charged a late this month?
Creative Cloud chat support (all Creative Cloud customer service issues)
http://helpx.adobe.com/x-productkb/global/service-ccm.html -
Function Modules to get First day of week, month, Year
Can anyone name the Function Modules for getting First day of week, month ,year.
to get first day of week use this function; WEEK_GET_FIRST_DAY
CALL FUNCTION 'WEEK_GET_FIRST_DAY'
EXPORTING
WEEK = '201107'
IMPORTING
DATE = l_date
EXCEPTIONS
WEEK_INVALID = 1
OTHERS = 2.
with DATE_COMPUTE_DAY function you can get date number in week.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
DATE = workdate
IMPORTING
DAY = day_of_week_num
EXCEPTIONS
OTHERS = 8.
CASE day_of_week_num.
WHEN 1.
hold_day_of_week = 'Monday'.
WHEN 2.
hold_day_of_week = 'Tuesday'.
WHEN 3.
hold_day_of_week = 'Wednesday'.
WHEN 4.
hold_day_of_week = 'Thursday'.
WHEN 5.
hold_day_of_week = 'Friday'.
WHEN 6.
hold_day_of_week = 'Saturday'.
WHEN 7.
hold_day_of_week = 'Sunday'.
WHEN OTHERS.
hold_day_of_week = 'invalid'.
ENDCASE. -
I have a new iPhone 5S. While trying to learn about it, I accidentally recorded a voice memo with no content. I cannot now figure out how to get rid of it. There is a banner across the top of my phone with this memo which I don't want. I have deleted it from iTunes but cannot get it off the phone. Help!
The banner usually indicates that the memo is "Paused." If you go back into voice memos, touch the word "Done" beside the big red pause button, give it a name, then it will show in a list. Touch the memo in the list then touch the trash can icon that should appear.
-
How to get rid of /j2ee prefix from URL when I use the OC4J via Oracle HTTP server
In 9iAS 9.0.2 Oracle HTTP Server (OHS) is pre-configured to assign requests to the Home OC4J instance via the URL-prefix "/j2ee"/
For example, the TEST servlet under OC4J would be passed through OHS using:
http://urmachine:urApachePort/j2ee/TEST
whereas in the standlone OC4J version, this URL works:
http://urmachine:urOC4JPort/TEST
How to get rid of /j2ee prefix from URL when I use the OC4J via Oracle HTTP Server?It is getting the url prefix from mod_oc4j.conf
under /ora9ias/Apache/Apache/conf
You can read more on this at
http://otn.oracle.com/docs/products/ias/doc_library/90200doc_otn/web.902/a92173/confmods.htm#1008977
-Prasad -
How to get informed by email about changes on service messages of the servi
How to get informed by email about changes on service messages of the service desk.
I need a kind of overview
functional details
and a very good guideline to do the implementation
Does anyone know how to do it?Hi,
Go throw this
Note 691303, Note 1041455
you will find each and every thing abt implementation .
Send mail to Message Processor in Service Desk
Points if helpfull
Regards,
Neni -
macbook hard drive crashed, i lost windows for mac, bought a disc when i got the mac, no longer have the disc, need my apps, don't wanna pay for it again. know how to get it quick without having to give my mac to the genius bar at apple store overnight?
What is it you need - Windows installer disc or something else? Your question is unclear. Could you be more specific?
-
Just upgraded iPhone 3GS to IOS5. Now in itunes I can see there's 21GB of Others. I have no idea what is that. I didnt have that before the upgrade. How to get rid of it? It's taken up all the space on the phone.
I posted a fix for this temporary issue earlier but here it is in short:
The memory "hog" that is "others" seems to be the OS as it's installing. It seems to want more than 12GB and you may get stuck at the point where iTunes tries to load everything back on and the iPhone has run out of space. What you need to to is un-check the "sync" box at the apps, music, podcasts and other sections, then click the button to sync iTunes with iPhone. This will result in iTunes deleting all the data it restored, but you'll put it back later. Once you caused the deletion of most of the data, iOS5 will resume installing and then "magically" shrink to less than 1GB. Then you can place check marks back in the boxes and re-sync all your apps and other data. You will have plenty or memory left.
I followed the above procedure and my iPhone works perfectly.
Hope this helps. -
How to get fiscal period based on date and Fiscal year?
Hi Guys,
Can anybody tell me how to get Fiscal period based on date and Fiscal Year or fiscal year variant?
Thanks,
Gopi.Hi,
Please refer the code below:
*: Report: ZFISCALYR :
*: Date : 2004 :
*: Description: Demonstrates how to return the corresponding fiscal :
*: year and posting period for a company code and posting :
*: date or posting date and fiscal year variant. :
REPORT zfiscalyr NO STANDARD PAGE HEADING.
TABLES: ekko.
PARAMETERS: p_bukrs TYPE ekko-bukrs,
p_bedat TYPE ekko-bedat.
DATA: gd_fiscalyr TYPE bapi0002_4-fiscal_year,
gd_fiscalp TYPE bapi0002_4-fiscal_period.
DATA: gd_fiscalyr2 TYPE T009B-BDATJ,
gd_fiscalp2 TYPE bapi0002_4-fiscal_period.
DATA: gd_periv TYPE t009-periv.
*START-OF-SELECTION.
START-OF-SELECTION.
* get fiscal year and period - (requires date and company code)
CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
EXPORTING
companycodeid = p_bukrs
posting_date = p_bedat
IMPORTING
fiscal_year = gd_fiscalyr
fiscal_period = gd_fiscalp.
* Alternative fiscal year function module
* - (requires date and fiscal year variant code from T009 table)
* gets first entry in fiscal year variant table (will need to choose
* correct one from table rather than just using first entry)
SELECT SINGLE periv
FROM t009
INTO gd_periv.
* get fiscal year and period
CALL FUNCTION 'DETERMINE_PERIOD'
EXPORTING
date = p_bedat
* PERIOD_IN = '000'
version = gd_periv
IMPORTING
period = gd_fiscalp2
year = gd_fiscalyr2
EXCEPTIONS
period_in_not_valid = 1
period_not_assigned = 2
version_undefined = 3
OTHERS = 4.
*END-OF-SELECTION.
END-OF-SELECTION.
WRITE:/ 'From function module: BAPI_COMPANYCODE_GET_PERIOD',
/ 'Fiscal year is:', gd_fiscalyr,
/ 'Fiscal period is:', gd_fiscalp.
SKIP.
WRITE:/ 'From function module: DETERMINE_PERIOD',
/ 'Fiscal year is:', gd_fiscalyr2,
/ 'Fiscal period is:', gd_fiscalp2.
Thanks,
Sriram Ponna.
Edited by: Sriram Ponna on Apr 17, 2008 8:59 PM -
How to get from Apple (officially) details on my iphone 5 (knowing the serial number): model, date of sale, the date of activation, etc. I bought a new iphone 5 on ebay.com - he was used. For a decision on my case ebay asks for this information ...
Apple will never reveal that info to you, since you were not the originally purchaser. However, you can get the date of sale by entering the SN here:
https://selfsolve.apple.com/agreementWarrantyDynamic.do
Warranty starts on the date of sale, which is most likely the date of activation, but not necessarily so.
Maybe you are looking for
-
b Urgent.Doubt in Scripts regarding itcsy.
Hi All, I have the requirement to modify the Standard Script (F140_ACC_STAT_01) and Print Program name is (RFKORD10) to add three fields at item level to display to print <b>Due Date ,Past Due and PO# number </b>.for these fields i am using <b>RF140
-
I don't have the option to download Bridge when using a PC. It is available on Mac. Am I missing something?
-
I am new to logic (7), and I have been pulling my hair out trying to figure out how to use the Custom Bank Messages window. I am trying to select banks from an old Proteus 1 synth, and I need to be able to send a sysex string. According to the refere
-
HT201359 I need to change my password & I've had charges on my account that I did not request
I need to change my password & I have charges on my account that I did not request
-
Is Adobe Acrobat XI compatible with Framemaker 8?
Installing the trial version of Acrobat has uninstalled the Adobe pdf printer instance from my Framemaker 8 installation. I can no longer make pdf's with Framemaker! Can these two Adobe products run on the same machine? How do I get Framemaker workin