DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: cast (date as int)??

  1. #1
    Join Date
    Mar 2002
    Posts
    303

    cast (date as int)??

    what is the equivalent function of "cast (date as int)" from sqlserver to Oracle?

    bensmail

  2. #2
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Just guessing - maybe something like (as I know almost nothing about SQL Server):

    SELECT TO_NUMBER(TO_CHAR(:some_date, 'J')) FROM my_table;
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  3. #3
    Join Date
    Mar 2002
    Posts
    303
    in sqlserver the query cast('01/01/2005' as int) return 38382

    i try ur query it returns 2453403.
    I don't know how sqlserver calculate this date formel.


    Bensmail

  4. #4
    Join Date
    Jan 2004
    Posts
    162
    Looks like SQL Server is returning days since 01/01/1900, so I think you would just adjust for the difference between that and Julian Date base, e.g.
    Code:
    SELECT TO_NUMBER (TO_CHAR (:some_date, 'J')) - 2415021
    FROM   dual;
    Last edited by padders; 03-07-2005 at 06:24 AM.

  5. #5
    Join Date
    Mar 2002
    Posts
    303
    Thank's it's work

Posting Permissions

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


Click Here to Expand Forum to Full Width