oracle - PL SQL birthday between two dates based on persons date of birth -
I am trying to see if a person falls in two dates despite the birthday date of birth. / P>
So far, I am trying to get the 'Deed' option to the day of the year. But what have I seen with my code that it seems that anyone is getting wrong results for the one year of December 31 and so on. I have tried to add 1, but there is no help from this. Even I have tried so far: -
select emp.employee_number, person.title, person.surname, person.first_forname, addr.line_one || '' || Addr.line_two || '' || Addr.line_three || '' || Addr.line_four || '' || Addr.postcode as address, LONG_DESC as post.long_desc, email.email_address, per.pers_mobile_tel_no as per mobile_no per person per emp emp per.person_ref = emp.person_ref on internal add addr addr per Post on php at pHspherson_ref = ph.person_ref internal post post on internal pH at address_ref = addr.ref. RRI Internal Including PL pl pl.post_ref = post.ref Where to_char ((TO_DATE (person.birth_date, 'DD-MM-YYYY'), 'Deed') & gt; = To_char (TO_DATE (Start_Date, 'DD-MON-YYYY')), 'ddd') and to_char (TO_DATE (person.birth_date, 'DD-MM-YYYY'), 'Deed') and lieutenant; = To_char (TO_DATE (: AND DIAT, 'DD-MOY-YYYY'), 'Deed') and Ph.and_dates are empty and public place_Number Inn ('501') in order of Emp.employee_number Any help on this will be appreciated. Thanks in advance.
The query is incorrect due to these conditions on 31 December:
to_char (TO_DATE (person.birth_date, 'DD-MM-YYYY')), 'ddd')> = to_char ((TO_DATE (: Start_Date, 'DD-MON-YYYY')), 'd D ') and to_char (TO_DATE (person.birth_date,' DD-MM-YYYY ')),' ddd ') & lt; = to_char ((TO_DATE (End_ Date,' DD-MON-YYYY ')),' Did You must use less or equal and greater or equal in both cases to_char ((TO_DATE (person.birth_date, '' (DD-MM-YYYY ')),' ddd ') To_char (TO_DATE,' DD-MON-YYYY ')),' ddd ') and to_char (TO_DATE (person.birth_date,' DD-MM -YYYY ')),' ddd ') & lt; = To_char (TO_DATE (TO_DATE, 'DD-MON-YYYY')), 'ddd')
or
to_char (TO_DATE (person Date of birth, 'DD-MM-YYYY'), 'Deed') & gt; = To_char (TO_DATE (Start_Date, 'DD-MON-YYYY')), 'ddd') and to_char ((TO_DATE (person.birth_date, 'DD-MM-YYYY'), 'Deed') & Lt; To_char (TO_DATE (: AND DIAT, 'DD-MON-YYYY')), 'DED') EDIT:
Query does not seem to solve your problem For example, suppose that birth day is 31.12.19 9, the start date is 01.06.19 and the end date is 01.02.1991. When you receive 'Deed', you have 365 for birthdays, 152 for start date and 32 for expiry date. However, 32 is less than 152, so you will not find the person with your output 31.12.19 9. Therefore, it is wrong to compare with 'Deed' value because it ignores the value of the year. Instead, you should compare entire dates with each other: TO_DATE (person.birth_date, 'DD-MM-YYYY') & gt; = TO_DATE (: Start_Date, 'DD-MON-YYYY') and TO_DATE (person.birth_date, 'DD-MM-YYYY') & lt; TO_DATE (: End_ Date, 'DD-MON-YYYY')
Comments
Post a Comment