Author |
Message |
Vidurudu
Pilla Bewarse Username: Vidurudu
Post Number: 54 Registered: 04-2011 Posted From: 98.238.222.108
Rating: N/A Votes: 0 (Vote!) | Posted on Thursday, May 12, 2011 - 2:30 am: |
|
I just saw NEXT_DAY function in Ravanabrahma's post. Looks like this query will always return last monday in May using NEXT_DAY. select next_day(to_date('0524','mmdd'), 'MONDAY') from dual |
Vidurudu
Pilla Bewarse Username: Vidurudu
Post Number: 53 Registered: 04-2011 Posted From: 98.238.222.108
Rating: N/A Votes: 0 (Vote!) | Posted on Thursday, May 12, 2011 - 2:23 am: |
|
I am not an expert in SQL, so my oracle query may not be straight forward. But, if you are finding the last monday of May in CURRENT year, the following query may work. select case when ( to_char(to_date('0525','mmdd'),'DY') = 'MON' ) then to_date('0525','mmdd') when ( to_char(to_date('0526','mmdd'),'DY') = 'MON' ) then to_date('0526','mmdd') when ( to_char(to_date('0527','mmdd'),'DY') = 'MON' ) then to_date('0527','mmdd') when ( to_char(to_date('0528','mmdd'),'DY') = 'MON' ) then to_date('0528','mmdd') when ( to_char(to_date('0529','mmdd'),'DY') = 'MON' ) then to_date('0529','mmdd') when ( to_char(to_date('0530','mmdd'),'DY') = 'MON' ) then to_date('0530','mmdd') when ( to_char(to_date('0531','mmdd'),'DY') = 'MON' ) then to_date('0531','mmdd') end from dual If you want to find the memorial day for some other year (past or future), you just need to change &year_yyyy with year (example: 2007, 2009 etc) in the below query select case when ( to_char(to_date('0525'||year_yyyy,'mmddyyyy'),'DY') = 'MON' ) then to_date('0525'||year_yyyy,'mmddyyyy') when ( to_char(to_date('0526'||year_yyyy,'mmddyyyy'),'DY') = 'MON' ) then to_date('0526'||year_yyyy,'mmddyyyy') when ( to_char(to_date('0527'||year_yyyy,'mmddyyyy'),'DY') = 'MON' ) then to_date('0527'||year_yyyy,'mmddyyyy') when ( to_char(to_date('0528'||year_yyyy,'mmddyyyy'),'DY') = 'MON' ) then to_date('0528'||year_yyyy,'mmddyyyy') when ( to_char(to_date('0529'||year_yyyy,'mmddyyyy'),'DY') = 'MON' ) then to_date('0529'||year_yyyy,'mmddyyyy') when ( to_char(to_date('0530'||year_yyyy,'mmddyyyy'),'DY') = 'MON' ) then to_date('0530'||year_yyyy,'mmddyyyy') when ( to_char(to_date('0531'||year_yyyy,'mmddyyyy'),'DY') = 'MON' ) then to_date('0531'||year_yyyy,'mmddyyyy') end from (select '&year_yyyy' year_yyyy from dual) |
Ravanabrahma
Bewarse Legend Username: Ravanabrahma
Post Number: 15700 Registered: 06-2004 Posted From: 72.129.47.227
Rating: N/A Votes: 0 (Vote!) | Posted on Wednesday, May 11, 2011 - 12:17 am: |
|
Blazewada:
antha kusalame baa...dinner kanichi netflix lo cinema soothanna inka.. |
Blazewada
Bewarse Legend Username: Blazewada
Post Number: 15974 Registered: 08-2008 Posted From: 206.53.152.176
Rating: N/A Votes: 0 (Vote!) | Posted on Wednesday, May 11, 2011 - 12:00 am: |
|
ravanabrahma:
baa papa ela undi. Ellarum kusalamaa. A Pat on your Back is few inches away from Kick on your Butt
|
Ravanabrahma
Bewarse Legend Username: Ravanabrahma
Post Number: 15699 Registered: 06-2004 Posted From: 72.129.47.227
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 11:52 pm: |
|
Penkonda_tiger:
|
Penkonda_tiger
Mudiripoyina Bewarse Username: Penkonda_tiger
Post Number: 4710 Registered: 06-2005 Posted From: 82.157.134.169
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 11:43 pm: |
|
Ravanabrahma:Given a date, can we find out if that is a saturday or sunday?
to_char(sysdate,'D') kanapade nijam: Good manners , kanapadanidhi: abusive language
|
Ravanabrahma
Bewarse Legend Username: Ravanabrahma
Post Number: 15698 Registered: 06-2004 Posted From: 72.129.47.227
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 11:27 pm: |
|
Symbol_of_king:first monday value ki +7 aythe 2nd ,+14 aythe 3rd ala vachestayi kada...am i missing something?????
idi koda try chesi chostha mama |
Symbol_of_king
Yavvanam Kaatesina Bewarse Username: Symbol_of_king
Post Number: 2084 Registered: 12-2005 Posted From: 76.21.187.173
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 9:58 pm: |
|
Ravanabrahma:similar ga 2nd, 3rd, fouth anedi elago chodali..
first monday value ki +7 aythe 2nd ,+14 aythe 3rd ala vachestayi kada...am i missing something????? |
Ravanabrahma
Bewarse Legend Username: Ravanabrahma
Post Number: 15697 Registered: 06-2004 Posted From: 72.129.47.227
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:58 pm: |
|
Lilliput: annai nuvvu adigindhi kochen aaa quiz aaa ...anni answers meere seppesthunnaru MOVIEART--bemmi.okamadiri
ikkada janalani adugthe google chestha..veellu cheppe vatini batti add chesukunte solution vachesthadi...pakka db lo rediff bhayya cheppadu last_day anedi |
Lilliput
Celebrity Bewarse Username: Lilliput
Post Number: 7797 Registered: 08-2010 Posted From: 129.107.30.107
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:53 pm: |
|
Ravanabrahma:
annai nuvvu adigindhi kochen aaa quiz aaa ...anni answers meere seppesthunnaru |
Ravanabrahma
Bewarse Legend Username: Ravanabrahma
Post Number: 15696 Registered: 06-2004 Posted From: 72.129.47.227
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:52 pm: |
|
anthe..2 times NEXT_DAY vesthe 2nd monday annattu..last_day vadithe last monday vachesthadi aa month lo |
Ravanabrahma
Bewarse Legend Username: Ravanabrahma
Post Number: 15695 Registered: 06-2004 Posted From: 72.129.47.227
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:48 pm: |
|
2nd ayithe NEXT_DAY ani 2 times pedithe saripodhemo..last anedi ela cheyyalo appudu..kiki |
Ravanabrahma
Bewarse Legend Username: Ravanabrahma
Post Number: 15694 Registered: 06-2004 Posted From: 72.129.47.227
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:47 pm: |
|
SQL> -- Finding the first Monday in the month of September. SQL> SELECT TO_CHAR(NEXT_DAY('01-SEP-97','Monday'),'MM/DD/YYYY HH:MM:SS AM') "Next_Day" from DUAL; similar ga 2nd, 3rd, fouth anedi elago chodali.. |
Vja
Yavvanam Kaatesina Bewarse Username: Vja
Post Number: 2147 Registered: 12-2009 Posted From: 72.184.151.231
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:43 pm: |
|
konchem tricky ee rendodii Strictly Jai Balayya
|
Ravanabrahma
Bewarse Legend Username: Ravanabrahma
Post Number: 15693 Registered: 06-2004 Posted From: 72.129.47.227
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:42 pm: |
|
Kalki:SAP lo ayyithe factory calendar ani untadi danni set seste dates anni ade sooskuntadi
oh..oracle lo undo ledo ala..kastha google setha.. |
Kalki
Bewarse Legend Username: Kalki
Post Number: 34758 Registered: 04-2005 Posted From: 168.161.192.16
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:39 pm: |
|
SAP lo ayyithe factory calendar ani untadi danni set seste dates anni ade sooskuntadi |
Ravanabrahma
Bewarse Legend Username: Ravanabrahma
Post Number: 15692 Registered: 06-2004 Posted From: 72.129.47.227
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:33 pm: |
|
Kalki:adi kooda veasy gaa raayocchu
ade soothanna google lo..adi koda rasetham ayithe ee month antha pandage.. Po need by date calculate seyyali kalkesh based on creation date and lead time. rendu kalipithe need by date vasthadi..aa creation date ki and need by date ki madhyalo dates weekend avvakodadu and holiday list lo unda kodadu..unte okati increment chesi malla test cheyyali same condition..so aa holiday list thayaru sesi oka table lo padedham ani working inka.. |
Ravanabrahma
Bewarse Legend Username: Ravanabrahma
Post Number: 15691 Registered: 06-2004 Posted From: 72.129.47.227
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:30 pm: |
|
the command that worked for me is select to_char(to_date('05/08/2011', 'mm/dd/yyyy'), 'd') from dual inka direct date type variable in pass chesthe ee to_date conversion avasaram ledu emo...inka adantha chosukovachu aa next |
Kalki
Bewarse Legend Username: Kalki
Post Number: 34757 Registered: 04-2005 Posted From: 168.161.192.16
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:29 pm: |
|
adi kooda veasy gaa raayocchu |
Ravanabrahma
Bewarse Legend Username: Ravanabrahma
Post Number: 15690 Registered: 06-2004 Posted From: 72.129.47.227
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:28 pm: |
|
Vja:select to_char(to_date('10-MAY-2011'),'day') from dual
yes baa..ippude chosa idi |
Ravanabrahma
Bewarse Legend Username: Ravanabrahma
Post Number: 15689 Registered: 06-2004 Posted From: 72.129.47.227
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:28 pm: |
|
Kalki:excel lo raayocchu easy gaa ...so SQl lo inka easy gaa raayocchu anukunta
satudat and sunday naa cheppatam easy nee..ippude test chesa.. select to_char(date, 'd') from dual return a number ranging from 0 to 6. 0 = saturday 1 = sunday 2 = monday . . . so if the value is 0 or 1 then I can say that is weekend. inka rule ni batti. I mean in the 5th month LAST monday of a given year anedi ee date anedi ela anedi chodali |
Kalki
Bewarse Legend Username: Kalki
Post Number: 34755 Registered: 04-2005 Posted From: 168.161.192.16
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:26 pm: |
|
rey daiper gaa knowledge daaram lo neekem pani |
Vja
Yavvanam Kaatesina Bewarse Username: Vja
Post Number: 2143 Registered: 12-2009 Posted From: 72.184.151.231
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:26 pm: |
|
select to_char(to_date('10-MAY-2011'),'day') from dual Strictly Jai Balayya
|
Kalki
Bewarse Legend Username: Kalki
Post Number: 34754 Registered: 04-2005 Posted From: 168.161.192.17
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:26 pm: |
|
=CHOOSE(WEEKDAY(A1),"Sun","Mon","Tue","Wed","Thu","Fri","Sat") A1 lo date iste vacchestadi |
Lilliput
Celebrity Bewarse Username: Lilliput
Post Number: 7793 Registered: 08-2010 Posted From: 129.107.30.107
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:25 pm: |
|
Kalki:excel lo raayocchu easy gaa ...so SQl lo inka easy gaa raayocchu anukunta
\blessme |
Kalki
Bewarse Legend Username: Kalki
Post Number: 34753 Registered: 04-2005 Posted From: 168.161.192.16
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:25 pm: |
|
excel lo raayocchu easy gaa ...so SQl lo inka easy gaa raayocchu anukunta |
Ravanabrahma
Bewarse Legend Username: Ravanabrahma
Post Number: 15688 Registered: 06-2004 Posted From: 72.129.47.227
Rating: N/A Votes: 0 (Vote!) | Posted on Tuesday, May 10, 2011 - 5:12 pm: |
|
Given a date, can we find out if that is a saturday or sunday? Also, how to find the date based on some rule. For eg: find the memorial day in 2011. Memorial day comes as the LAST Monday in Month May. How to find the date if based on Last monday in 5th month? |