Functions for date datatype

Dear ALL...
Someone know some function for query months, years, days from date columns....???
Example for MSSQL...select datepart(date collumn) from table....select month(date column) from table....etc
I´m studing Oracle alone to get a OCP (OCA first)......the bad thing...I Work with the MSSQL.. (to me, Oracle is the best RDBMS)...
Thks
Daniel

Hi Daniel,
Well I saw that you come from Brazil and as you are studying Oracle by yourself, take a look on my blog http://mportes.blogspot.com - There you're going to find a lot of technical stuff in Portuguese. For intance you might interest on this
http://mportes.blogspot.com/2005/11/trabalhando-com-intervalos-de-datas.html
About your question, you can start with
SQL> select to_char(sysdate, 'Mon') from dual;
TO_
May
1 row selected.
SQL> select to_char(sysdate, 'Month') from dual;
TO_CHAR(S
May
1 row selected.
SQL> select to_char(sysdate, 'Month', 'nls_date_language=portuguese') from dual;
TO_CHAR(S
Maio
1 row selected.To find more information, I suggest you stop by
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/functions180.htm#SQLRF06129
and try out http://tahiti.oracle.com there you will find all docs from Oracle (free).
And so on...

Similar Messages

  • Creating stored outlines for date datatype bind variable

    While trying to create stored lines for a query having date datatype I get
    ORA-00932: inconsistent datatypes: expected DATE got NUMBER error:
    desc table_t1;
    col1 number,
    datecol date
    CREATE OR REPLACE OUTLINE TEST FOR CATEGORY TEST
    ON
    select * from table_t1
    WHERE T1.COL1 IS NOT NULL
                                          AND T1.DATECOL BETWEEN TRUNC (:D1)
                                                                   AND TRUNC (:D2)
                                                                       + 1Can someone please help me what am I doing wrong?
    I also tried to declare variable of date from sqlplus but it seems sqlplus doesn't have any support for date datatype var declaration as bind variable.
    Thanks
    Kev
    Edited by: Kevin_K on Jan 3, 2011 4:48 AM

    I think in this case you would have to take an approach like this:
    alter session set set create_stored_outlines=true;
    run your sql-statement (with a date bind variable), using anonymous plsql block.
    alter session set create_stored_outlines=false;
    Not sure though. It's been a while since I played around with outlines.

  • Math functions for dates

    Hello,
    Have you ever used a math function for dates (MMDDYYYY) not just a number? I'm looking to send an email out based on date field. For example, if someone's contract expires on 1/1/2016, I'd like to send them out emails 30, 152, 212 and 335 days before that date. Right now, we have fields set up for those 30, 152, 212 and 335 days and would like to know if there's a math function that would automatically fill them in dynamically based on their contract exp. date.
    Thanks for your help and suggestions.

    rmabrey wrote:
    I have the calculator working but I am having trouble figuring out thow to do a square root function, nth factorial, absolute value, and Fibonacci. java.lang.Math.sqrt()
    nothing for factorial - write your own.
    java.lang.Math.abs()
    nothing for Fibonacci - write your own.
    %

  • TRUNC function for DATE

    Another thread from today made me think of the basics of TRUNC function used for DATEs. I am confused about what it acutally does.
    This is what Oracle Documenations says about TRUNC function without format (like 'DD-MON-YY')
    "If you omit fmt, then date is truncated to the nearest day" (Oracle 10Gr2 SQL reference, B14200-02)
    SQL> alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS';
    Session altered.
    Query 1.
    SQL> SELECT SYSDATE FROM DUAL;
    SYSDATE
    06-DEC-2007 14:22:01
    Query 2.
    SQL> SELECT TRUNC(SYSDATE) FROM DUAL;
    TRUNC(SYSDATE)
    06-DEC-2007 00:00:00I have three questions
    1)Since it 2:22 pm , shouldn't the result of TRUNC(SYSDATE) ie Query 2. be 7-Dec-2007 ?
    2) What difference does TRUNC function make in the code apart from setting the time to 00:00:00?
    3) Is it safer to add TRUNC for DATEs in the code?
    SQL> select sysdate-1 from dual;
    SYSDATE-1
    05-DEC-2007 14:27:51
    SQL> select trunc(sysdate) - 1 from dual;
    TRUNC(SYSDATE)-1
    05-DEC-2007 00:00:00Added third question
    Message was edited by:
    user609308

    it's not a function that rounds up date's it purely truncates to the granularity that you want.
    So TRUNC(sysdate) still returns a date datatype (which still contains a date and time portion) but the time portion is truncated i.e. cleared down to it's lowest limit.
    Likewise if you TRUNC(sysdate,'YYYY') then it will truncate to the year and take months, days, hours, mins and secs down to their lowest limit hence giving you 1st January of that year with 00:00:00 as the time.
    It's very simple really.

  • Function for dates

    Hi Experts!
    i want to calculate months b/w 2 dates , is there function for this . can i find days and year  also .plz tell me .
    thanks.

    HAI TRY THIS
    REPORT  ZSAN_SDN2.
    SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME.
    PARAMETER:
              N1 TYPE T,
              N2 TYPE T.
    DATA:     DN1 TYPE T,
              DN2 TYPE T,
              DN3 TYPE I,
              DN4 TYPE I,
              DN6 TYPE I,
              DN5 TYPE I.
    SELECTION-SCREEN:
    BEGIN OF LINE,
    PUSHBUTTON 2(10) BUT1 USER-COMMAND CALC,
    PUSHBUTTON 13(10) BUT2 USER-COMMAND EXIT,
    END OF LINE.
    SELECTION-SCREEN END OF BLOCK B1.
    AT SELECTION-SCREEN.
      CASE SY-UCOMM.
        WHEN 'CALC'.
          MOVE: N1 TO DN1,
                N2 TO DN2.
          DN3 = DN2 - DN1 .
          DN3 = DN3 MOD 86400.
          DN4 = DN3 / 3600 .
          DN6 = DN3 / 60 .
          DN5 = DN6 MOD 60.
          DN3 = DN3 MOD 3600 .
          DN3 = DN3 MOD 60 .
          LEAVE TO LIST-PROCESSING.
          SET PF-STATUS SPACE.
          WRITE: / DN4, 'hours'.
          WRITE: / DN5, 'minutes'.
          WRITE: / DN3, 'seconds'.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    INITIALIZATION.
      BUT1 = 'calc'.
      BUT2 = 'exit'.

  • Between function for dates in Docmd.OpenReport rptName,,[date-filed] BETWEEN #date1# AND #date2# .. NOT WORKING

    Please assist, this is a nightmare indeed.
    Am trying to filter records in a report using the BETWEEN function, as below:
    strCondition = "Format([tblOrderLineTrack_main].[dtAllocation],'dd/MM/yyyy') BETWEEN Format(#06/02/2015#,'dd/MM/yyyy') AND Format(#07/03/2015#,'dd/MM/yyyy')" 
    DoCmd.OpenReport strDocName, acViewPreview, , strCondition, acWindowNormal
    The report is bringing up all records including those outside the specified range. What could be wrong with this???? Please assist, I am going nuts over this...

    The date literals I used are in the
    ISO standard for date notation of YYYY-MM-DD so are internationally unambiguous.  The only circumstance I can envisage in which it would not return the rows expected would be the extremely unlikely one where all the rows with dates in the range happen
    to have a date of 7 March 2015, and all have a non-zero time of day element.  There is no such thing in Access as a date value, only a date/time value so #2015-03-07# in fact represents the point of time at midnight at the start of 7 March 2015. 
    Any rows with date/time values of that date, but with a non-zero time of day would consequently fall outside the range.
    The above is so unlikely that I can't believe it to be the case, but the bullet-proof syntax would be:
        strCondition = "dtAllocation  >= #2015-02-06# " & _
              "AND dtAllocation < #2015-03-07#+1"
    i.e. all date/time values on or later than the start of the first day of the range (#2015-02-06 00:00:00#) and before the start of the day following the end of the range (#2015-03-08 00:00:00#)
    Assuming that the dtAllocation column is of date/time data type, and is returned as such in the report's RecordSource, not as a formatted string expression, I can see no reason on the information available why the above should not work, so if the report is
    still not returning any data some other reason not apparent to us must be suspected.  We are not in a position to debug the report, however, so what that might be I can't say.
    Ken Sheridan, Stafford, England

  • TO_CHAR Function for dates in UTF8 database

    Hi,
    Our database is UTF8 enabled infact we are using AL32UTF8 encoding. When we are running the following query then the results are displayed in Japanese instead of English for the 'DAY' and 'DY' clause.
    SELECT TO_CHAR(SYSDATE,'DAY') DAY,TO_CHAR(SYSDATE,'YEAR') YR,TO_CHAR(SYSDATE,'DY') DY,TO_CHAR(SYSDATE,'MON') MON FROM DUAL;
    DAY YEAR DY MON
    &#28779;&#26332;&#26085; TWO THOUSAND SIX &#28779; JAN
    Can anyone please tell me what is the reason behind this. Our other nls parameters are like;-
    SQL> sho parameter nls
    NAME TYPE VALUE
    nls_calendar string
    nls_comp string
    nls_currency string
    nls_date_format string
    nls_date_language string
    nls_dual_currency string
    nls_iso_currency string
    nls_language string AMERICAN
    nls_length_semantics string BYTE
    nls_nchar_conv_excp string FALSE
    nls_numeric_characters string
    nls_sort string
    nls_territory string AMERICA
    nls_time_format string
    nls_time_tz_format string
    nls_timestamp_format string
    nls_timestamp_tz_format string
    Thanks & Regards,
    Sudipta

    The date literals I used are in the
    ISO standard for date notation of YYYY-MM-DD so are internationally unambiguous.  The only circumstance I can envisage in which it would not return the rows expected would be the extremely unlikely one where all the rows with dates in the range happen
    to have a date of 7 March 2015, and all have a non-zero time of day element.  There is no such thing in Access as a date value, only a date/time value so #2015-03-07# in fact represents the point of time at midnight at the start of 7 March 2015. 
    Any rows with date/time values of that date, but with a non-zero time of day would consequently fall outside the range.
    The above is so unlikely that I can't believe it to be the case, but the bullet-proof syntax would be:
        strCondition = "dtAllocation  >= #2015-02-06# " & _
              "AND dtAllocation < #2015-03-07#+1"
    i.e. all date/time values on or later than the start of the first day of the range (#2015-02-06 00:00:00#) and before the start of the day following the end of the range (#2015-03-08 00:00:00#)
    Assuming that the dtAllocation column is of date/time data type, and is returned as such in the report's RecordSource, not as a formatted string expression, I can see no reason on the information available why the above should not work, so if the report is
    still not returning any data some other reason not apparent to us must be suspected.  We are not in a position to debug the report, however, so what that might be I can't say.
    Ken Sheridan, Stafford, England

  • How can i make a pl/sql function for BLOB datatype

    hi..anyone here who is very familiar about BLOB datatype. i have a COLUMN_ID, COLUMN_A in a certain TABLE_1. COLUMN_A is blob datatype that contains almost 250,000rows
    SQL>select column_A from table_1 where column_id=1234567
    column_A
    00000001000000010000000606D4E833074B69EC06D4E91F074CO18406D50C58074C031E
    how can i make a user-defined function to compute and convert this blob datatype into decimal length value. this hex value are points in the map.. the function must contain
    1.get the length of a blob then
    2.convert blob to variable hexadecimal characters by parsing it into 8
    3.to_number function or other function used to convert haxadecimal characters to decimal numbers
    4.phythagorean formula to compute length between two points. this is the formula i think LENGTH =
    SQRT(power((coordinate_x-prev_coordinate_x),2)+power((coordinate_y-prev_y),2));
    after this when i type this
    SQL>select user_function(column_A) from table_1 where column_id=1234567
    user_functions(column_A)
    --output length will be in decimal value already
    the function will goes like this
    step1 is to get the blob length
    00000001000000010000000606D4E833074B69EC06D4E91F074CO18406D50C58074C031E
    step2 is parsing of data by eights
    00000001 =>1
    00000001 =>1
    00000006 =>6 (number of coordinates)
    06D4E833 => X1
    074B69EC => Y1
    06D4E91F => X2
    074CO184 => Y2
    06D50C58 => X3
    074C031E => Y3
    step3 to_number function used to convert hex char to decimal
    step4 compute by phytagorean (NOTE ! when computing length the third parsed eight will tell how many coordinates are there..the number of coordinates is ranging from 2 up to E..above example shows 6 coordinates so it means
    LENGTH1 =
    SQRT(power((X2-X1),2)+power((Y2-Y1),2));
    LENGTH2=
    SQRT(power((X3-X2),2)+power((Y3-Y2),2));
    TOTAL LENGTH=LENGTH1 + LENGTH2
    thanks

    its my first time to use that.There's got to be a first tiem for anything. Be brave.
    btw if theres more easy suggestion pls feel free..Well of course the easiest solution would be if the calling program passed in the parameters as separate arguments instead of glomming them together in a string that has to be parsed. This sort of kluj really ought not to have survived into C21.
    Cheers, APC

  • How to use min-max functions for date in transformation in bpel?

    Hi,
    I have a requirement where i need to map earliest date of a Source field among all the dates to a target field in a transformation file in BPEL. There are functions called max-value-among-nodeset and min-value-among-nodeset in mathematical functions but they can be used only for numbers and strings.How to do these with dates?
    Thanks,
    Prasanna

    I exactly have the same requirement.Are you able to solve this?
    Its very urgent.Please help me.

  • How to use function for 'date' - 30 mins?

    Hi,
    I need to subtract 30 mins from date-time and display value in report?
    Any function?
    Thanks!
    Edited by: user12427117 on Mar 11, 2011 10:20 AM

    Date should be in canonical format
    i.e. YYYY-MM-DDThh:mm:ss+HH:MM
    or atleast YYYY-MM-DD
    when you want to divide you should have it as '1 div 48' and not 1/48
    Havent tried this one. So cant confirm if it works for mins

  • Function for Date Validation

    Hi,
    Can anyone tell me a Function Module to Valdate Date?
    Thanks & Regards
    Sheela

    Thanks for the Quick response.
    But i want a FM which will validate Every Date entered(Date format)
    Thanks Once again
    Regards
    Sheela

  • FOR DATE DATATYPE

    Good Morning Everyone,
    We only knew NVL for Number. Now, we would like to return all dates.
    SELECT C.START_DATE, C.END_DATE, C.CREATE_DT, C.MODIFIED_DT
    FROM CLASSES C
    WHERE C.C_ID = 31
    30-JUN-00 22-DEC-07 30-FEB-10
    1 row selected.
    Thanks in advance,
    S!G

    Sea!Gull wrote:
    Good Morning Everyone,
    We only knew NVL for Number. Now, we would like to return all dates.
    SELECT C.START_DATE, C.END_DATE, C.CREATE_DT, C.MODIFIED_DT
    FROM CLASSES C
    WHERE C.C_ID = 31
    30-JUN-00 22-DEC-07 30-FEB-10
    1 row selected.
    Thanks in advance,
    S!GNot not exactly sure what your question is......"Now, we would like to return all dates." Ok, take out the where clause and all the dates for the table should return for the columns you listed.
    Regards
    Tim Boles

  • User response function() for Date Prompt

    Hi Experts,
    I have the requirement to show the date enterted in the prompt in the column of the webi report.
    I used the User response function e.g. =(UserResponse("Report Date").
    Now I am getting the value as 5/14/2014 12:00:00 AM. I dont want to see the time stamp with the date and aslo i want to change the format of the
    date to - yymmdd like 140514.
    Please provide your inputs.
    Thanks,
    Abhimanyu Sharma.

    Hi Arjit,
    I closed the thread.
    Can you please help in the below issue :
    I have two columns in the BEX report:
    1. "Local Count" which is restricted with Multiple Single Value variable "ZIN_CITY" on navigational Attribue 0ROUTE__0ROUTEID.
    2. "Out Count " which is restricted with Multiple Single Value variable "ZOUT_CITY" on navigational Attribue 0ROUTE__0ROUTEID.
    I put value 100 in prompt ZIN_CITY and 200 in ZOUT_CITY when i run this query in BOBJ WEbi.
    But i am getting the error - Not able to retrieve data. i checked in the backend and data is present and also Bex query is working fine.
    IF i change the property of variable to Single value then it is working fine in WEBi.
    Also i tried another method - irresprctive of setting the prompt in BEx on Nav attr 0ROUTE__0ROUTEID, i created the prompt in BOBJ WEBi, but LOVs (list of values)are not coming in the prompt.
    Please suggest on this?

  • Is there any in-built function for date compare?

    I need function which compare dates?

    Hi,
    You can simply use > , <,etc.,
    Check this sample code.
    data : d1 type RM06B-EEIND ,
           d2 type sy-datum.
    d1 = sy-datum.
           CALL FUNCTION 'DATE_IN_FUTURE'
             EXPORTING
               anzahl_tage                   = '-7'
               import_datum                  =  d1
            IMPORTING
              EXPORT_DATUM_EXT_FORMAT       =  d2
              EXPORT_DATUM_INT_FORMAT       =  d2
    if d1 < d2.
    write 'h'.
    endif.

  • NWEngine function for date

    Is there a list of nwengine functions anywhere?  I take it to be a VBscript capable, but there's no guide on how to get it to do simple things like date and time in any of the sample scripts.  It is unable to resolve the %date% and %time% variables,
    NwEngine.Variables.ResolveString("%date%")
    yet it resolves other variable successfully,
    NwEngine.Variables.ResolveString("%windir%\saplogon.ini")
    NwEngine.Variables.ResolveString("%username%")
    What gives?

    Dim MyTime
    MyTime = CStr(Time)   ' Return current system time.
    Dim MyDate
    MyDate = CStr(Date)   ' MyDate contains the current system date.

Maybe you are looking for