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!

get number of week day - no matter what national locale is used

Discussion in 'SQL PL/SQL' started by ecivgamer, Aug 16, 2014.

  1. ecivgamer

    ecivgamer Active Member

    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    130
    Hi all,

    My need is to get number of week day - no matter what national locale is used.
    For example, Saturday is 6th day of week in my country, because week starts from Monday.
    I've heard that some countries start week from Sunday.
    So my need is to compile code that doesn't depend on national locale.
    How do I perform it?


    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    "CORE 11.2.0.1.0 Production"
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
     
  2. ecivgamer

    ecivgamer Active Member

    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    130
    The solution:

    SELECT 1 + TRUNC (SYSDATE) - TRUNC (SYSDATE, 'IW') T1 FROM DUAL