How to get the week day name from a date?

后端 未结 2 1057
误落风尘
误落风尘 2020-12-05 12:23

Given 03/09/1982 how can we say it is which week day. In this case it will be Tue.

Is it possible to get in a single query?

相关标签:
2条回答
  • 2020-12-05 13:05
    SQL> SELECT TO_CHAR(date '1982-03-09', 'DAY') day FROM dual;
    
    DAY
    ---------
    TUESDAY
    
    SQL> SELECT TO_CHAR(date '1982-03-09', 'DY') day FROM dual;
    
    DAY
    ---
    TUE
    
    SQL> SELECT TO_CHAR(date '1982-03-09', 'Dy') day FROM dual;
    
    DAY
    ---
    Tue
    

    (Note that the queries use ANSI date literals, which follow the ISO-8601 date standard and avoid date format ambiguity.)

    0 讨论(0)
  • 2020-12-05 13:16

    To do this for oracle sql, the syntax would be:

    ,SUBSTR(col,INSTR(col,'-',1,2)+1) AS new_field

    for this example, I look for the second '-' and take the substring to the end

    0 讨论(0)
提交回复
热议问题