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!

Converting to sql

Discussion in 'General' started by Pasi, Jan 31, 2018.

  1. Pasi

    Pasi Newly Initiated

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    30
    Location:
    USA
    Hi,

    I have below code and trying to convert to sql any help would be great?
    Thanks,.
    P.

    TRUNC ( ( ADD_MONTHS(A.SERVICE_DT - 1 , 7) ), 'MONTH')
     
  2. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,645
    Likes Received:
    372
    Trophy Points:
    1,430
    Location:
    Aurora, CO
  3. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    769
    Likes Received:
    148
    Trophy Points:
    830
    Location:
    Russian Federation

    This code, provides from you ,is working and at sql engine and pls/sql engine.

    Code (Text):

    DECLARE
     t DATE := TRUNC ( ( ADD_MONTHS(SYSDATE- 1 , 7) ), 'MONTH');
     t1 DATE;
    BEGIN
        SELECT TRUNC ( ( ADD_MONTHS(SYSDATE - 1 , 7) ), 'MONTH') INTO t1 FROM dual;
      dbms_output.put_line('t='||to_char(t,'dd.mm.yyyy hh24:mi:ss')||' t1='||to_char(t,'dd.mm.yyyy hh24:mi:ss'));
    END;
    /
     
    What is your question?
     
  4. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,645
    Likes Received:
    372
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    The OP wants similar code for Transact-SQL. A link to that documentation has been posted
     
  5. Pasi

    Pasi Newly Initiated

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    30
    Location:
    USA
    Thanks but no, this is not SQL function Trun(Ad_month) is Oracle I have tried no of times to convert but its a bit Tricky to convert it to SQL. Also I know about the link I thought may be in this community can shed lights to this function.
     
  6. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,645
    Likes Received:
    372
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    This is an Oracle community, not SQL Server. You may be better served finding a SQL Server forum.