-4

I want to select current system date from a table of DOB(date of birth) in member_info table

DESIGNATION                             DOB       GENDER   MARITAL_STATUS
STUDENT                             4-Jun-1996      MALE         SINGLE
BUSINESS OWNER                      13-Sep-1981     MALE         MARRIED
BUSINESS OWNER                      1-Jan-1959      MALE         MARRIED
Sathyajith Bhat
  • 21,321
  • 22
  • 95
  • 134
  • Do you mean the most recent date among the dates available ? – Rohit Bandooni Apr 07 '15 at 07:21
  • MySQL and/or Oracle? (Date/time is one of the areas where too many dbms products aren't standard compliant.) – jarlh Apr 07 '15 at 07:23
  • 2
    "Please reply quickly"? This site is run by volunteers. You have no SLA with us. So it's pretty cheeky to demand a snappy response. – APC Apr 07 '15 at 07:40
  • i repeat my question i have a table of member_info in which i want two columns records first DOB and second contact No i want to wish happy birthday whose data of birth (DOB) is match with system date means current date – Danish Altaf Apr 07 '15 at 08:01
  • 1
    And I repeat my question, have you managed to find out if your using MySQL or Oracle? – jarlh Apr 07 '15 at 08:02

1 Answers1

1

In Oracle, you could use SYSDATE to compare the date and month with TO_CHAR and proper format.

For example,

SQL> WITH dates AS(
  2  SELECT 'Mark' names,  to_date('4-Jun-1996', 'DD-Mon-YYYY') dt FROM dual UNION ALL
  3  SELECT 'Henry' names, to_date('7-Apr-1981', 'DD-Mon-YYYY') dt FROM dual
  4  )
  5  SELECT names,
  6    CASE
  7      WHEN TO_CHAR(dt, 'MM/DD') = TO_CHAR(sysdate, 'MM/DD')
  8      THEN 'Happy Birthday'
  9      ELSE 'Not today'
 10    END is_bday_today
 11  FROM dates;

NAMES IS_BDAY_TODAY
----- --------------
Mark  Not today
Henry Happy Birthday

SQL>
Lalit Kumar B
  • 47,486
  • 13
  • 97
  • 124