1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Using Select query.,

Discussion in 'SQL PL/SQL' started by Vicky, Mar 18, 2014.

  1. Vicky

    Vicky Forum Advisor

    Messages:
    261
    Likes Received:
    11
    Trophy Points:
    260
    Location:
    Chennai
    Can any1 tel me.,how to get values, weekday as 'wd' and weekend as 'we' based on the current day using select query alone., for ex: As today is a weekday, when I execute the select query, it should come as WD..,


    Tnx.,
     
  2. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,347
    Likes Received:
    348
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    You can use the 'D' format specifier to return the numeric assignment for the day of the week (1==Sunday, 7==Saturday) then use a query such as this:


    Code (SQL):

    SQL> SELECT CASE
      2     WHEN to_char(sysdate, 'D') IN (1,7) THEN 'WE' ELSE 'WD' END WD_WE
      3  FROM dual
      4  /


    WD
    --
    WD


    SQL>
     
     
    Vicky likes this.