Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2003
    Posts
    20

    Unanswered: Eqivalent of @@DATEFIRST in oracle

    Can anybody tell me what is the equivalent or alternative or work around of @@DATEFIRST in oracle.

    TIA
    Alok

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Eqivalent of @@DATEFIRST in oracle

    Perhaps - if you can explain what @@DATEFIRST does...?

  3. #3
    Join Date
    Sep 2003
    Location
    Assen, Nederland
    Posts
    55
    He's talking about a global fxn in sql server.
    Hope that helped...
    Visit My Website : http://www.oraflame.com
    _____________________________
    Tarry Singh

    OCP DBA 8i
    Currently: SQL Server DBA 7,2000
    Oracle, PHP Programmer

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Originally posted by tarry
    He's talking about a global fxn in sql server.
    Yes, I was wondering what the function does - so that I could suggest an Oracle equivalent. An example would help!

  5. #5
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    By Googling I see that @@DATEFIRST returns the default first day of the week, which is set by some other function.

    I don't believe Oracle has an equivalent. To get the day of the week for a date in Oracle is like: TO_CHAR(sysdate,'D')

    What this returns depends on the local convention determined by the NLS_TERRITORY system parameter. This is set typically for the country you are in e.g. if NLS_TERRITORY='AMERICA', Monday is day 1.

    You can't set the first day of the week arbitrarily. If you need to do that, you would need to write your own function (I believe).

  6. #6
    Join Date
    Sep 2003
    Location
    Assen, Nederland
    Posts
    55
    I would like to see the functionality of that function myself in the realworld.(I'm sure there is)

    example is that you can manipulate the default settings normally dedault is us eng 7

    so if you set wednesday as firstday like this then here for instance 2nd day would be thursday and tuesday would be the 7th...

    Code:
    C:\WINNT\system32>osql -E -S cc345772-a\nick2k
    1> use master
    2> go
    1> set datefirst 3
    2> select @@datefirst as 'First Day', datepart(dw, getdate()) as Today
    3> go
     First Day Today
     --------- -----------
             3           7
    
    (1 row affected)
    1>
    Hope that helped...
    Visit My Website : http://www.oraflame.com
    _____________________________
    Tarry Singh

    OCP DBA 8i
    Currently: SQL Server DBA 7,2000
    Oracle, PHP Programmer

  7. #7
    Join Date
    Sep 2003
    Location
    The Netherlands
    Posts
    311
    hi,

    with the NLS settings in mind, you can use the trunc(sysdate,'D') to select the date of first day of this week, or replace the sysdate with your own date to retrieve the first day in that week.
    But beware of your NLS settings as in america monday is the first day of the week and for example in the Netherlands sunday is (or was it the other way around ?)

    Hope that helps
    Edwin van Hattem
    OCP DBA / System analyst

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •