To extract a day from a Date variable

Hi
I have a date variable and i want to get the day into a PL/SQL variable.Can you tell me how to do that .
eg I have 12/30/2002 (MMDDYYY)
and i want 30 in another variable ..
Thanks in a advance

SQL> declare
  2  ln number;
  3  begin
  4  ln := to_char(sysdate, 'DD');
  5  dbms_output.put_line(ln);
  6  end;
  7  /
22
PL/SQL procedure successfully completed.
SQL>
[pre]
Piece of cake.  No, thanks, I've just had breakfast.
APC                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Extract data on report between last 30 days from current date.

    Hi Experts,
    Ealrier i had provided user promt to select the date range, now i need to schedule the report for this i have to set the date between last 30 days from current date.
    How can i add this in formaula on record selection.
    before:
    {pm_process.pm_creation_date} in {@Start Date to UTC} to {@End Date to UTC}
    I tried:
    {pm_process.pm_creation_date} in CurrentDate() - 30 to CurrentDate()
    But this is diplaying me only data of 30th date from current date.
    Please advice.

    Hi Brian,
    Thank you!
    1. I have not created any function for {pm_process.pm_creation_date} in [CurrentDate() - 30 to CurrentDate()] i am just adding this on Record Selection and its not helping.
    2. {pm_process.pm_creation_date} in Last30Days; this is throwing below error.
    please advice what to be done?

  • How to calculate number of days from a date field

    Dear BW Experts.
    I have a field 'Create Date' in the BEx query. Now we need to create a variable which should give the number of days from the date of running the query (sy-datum) to the Create Date.
    This will help the users to get records which are say, 30 days old (Sy-datum - create date = 30) or 10 days old etc.
    Could you suggest as to how to create this variable.
    Thanks,
    Sai

    Hi,
    Step 1: Create variable on "Create Date" with User entry processing type
    Step 2: Create a restricted KF for Sales & restrict it on "Create Date" to get "Sales on day"
    Step 3: Manipulate  the values of "Create Date" on which you could restrict  "Sales" again and again to get other values
    Step 4: Create one variable (ZPUTMNTH) for u201CMonth to Dateu201D with processing by u201CCustomer Exitu201D. This variable was created  on u201CDateu201D characteristics.
    Step 5 : Goto C-mod t-code and use EXIT_SAPLRRS0_001
    to calculate "month to date" user input is "Calday" Key Date
    WHEN 'ZPUTMNTH'.
    IF I_STEP = 2. "after the popup
    LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
    WHERE VNAM = 'ZPDATE'.
    CLEAR L_S_RANGE.
    L_S_RANGE-LOW = LOC_VAR_RANGE-LOW(6). "low value, e.g.YYYYMM (200606) part of key date (20060625)
    L_S_RANGE-LOW+6(2) = '01'. u201C low value e..g. YYYYMM01 (20060601)
    L_S_RANGE-HIGH = LOC_VAR_RANGE-LOW. "high value = input
    L_S_RANGE-SIGN = 'I'.
    L_S_RANGE-OPT = 'BT'.
    APPEND L_S_RANGE TO E_T_RANGE.
    EXIT.
    ENDLOOP.
    ENDIF.
    Assign if helps.....
    Regards,
    Suman

  • Subract n days from a date

    Using 2004s service pack 10.  Is there a way to subtract x number of days from a date using a formula?  I saw an earlier post that said to use function module RP_Calc_Date_In_Interval but when I search for this it says it doesn't exist.  Is it called something else in 2004s?  Is the only way to accomplish this using a function module?

    If formula variable does not work and if the "no of days is a fixed number", then next alternative is to have a routine in transformation and make the subtraction.
    Ravi Thothadri

  • How to subtract a day from the presentation variable @{system.currentTime}

    Hello,
    How can subtract a day from the presentation variable - @{system.currentTime}
    I use the above as a title in the report. However I want to subtract a day from the above variable. How can I accomplish it?
    Thanks.

    Hi,
    Did you try the steps which I mentioned above. You can use TIMESTAMPADD function in many places in your report but I think not in title section of the title view.
    Also you can try using Narrative view instead of title view to achieve this. Follow below steos:
    * Pull another column in the report and change its fx to TIMESTAMPADD(SQL_TSI_DAY, -1, @{system.currentTime})
    * Now go to the Narrative view and add the below text in Narrative section of the view.
    Active Person Report as of @1
    Here @1 assuming the new column created is placed before all the columns in the request.
    * Also set the 'Rows to Display' as 1.
    * Delete Title view from the report and this narrative view on top of your report.
    Hope this helps.
    Thanks

  • Trying to subtract days from a date

    Im trying to subtract days from a date.
    When i use this query:
    select sysdate-:p21_DAYS_OLD from dual;
    it displays the correct date but not in the correct format. It is displaying 12-AUG-09 instead of 08/12/2009.
    I tried this query but i get the ORA-01722: invalid number error.
    select to_char(sysdate,'MM/DD/YYYY')-(:p21_DAYS_OLD) from dual;
    Can someone help me please?
    Deanna

    Dclipse03 wrote:
    Im trying to subtract days from a date.
    When i use this query:
    select sysdate-:p21_DAYS_OLD from dual;Just set the NLS_DATE_FORMAT parameter for your session and execute the above query.
    ALTER SESSION SET NLS_DATE_FORMAT='MM/DD/YYYY'
    /

  • Payment term - 90 days from document date on 15th of the month

    Helllo,
    Can anybody please tell me how to configure following payment term?
    90 days from document date on 15th of the month i.e. as follows:
    u2022     Document date = 03.01 => Due date = 15.04 (90 days completes on 03.04)
    u2022     Document date = 15.01 => Due date = 15.04 (90 days completes on 15.04)
    u2022     Document date = 27.02 => Due date = 15.06 (90 days completes on 28.05)
    u2022     Document date = 18.03 => Due date = 15.07 (90 days completes on 16.06)
    Regards,
    CHetna Pant

    Dear,
    Define no 'fixed day' and 'additional months'. Go to payment terms section and enter 90 in 'No. of days'

  • How to add days to a DATE variable?

    Hi,
    I want to run a query based on my date variable with subtracting 7 days from it. Thanks.
    p_date DATE;
    Select * from table where theDate between to_date(p_date , 'yyyy/mm/dd') to_date(p_date - 7, 'YYYY/mm/dd');
    Thanks.

    If p_date is a DATE data type variable why are you using TO_DATE? It is, by definition, already a date.
    WHERE theDate BETWEEN (p_date-7) AND p_date;

  • Subtracting Days from a Date

    Am using Acrobat Pro 9 for Windows.  I have a form where I want to subtract days from Date1 and the result is Date2.  The Date1 and Date 2 text boxes are unformatted.  I've tried reading the "date" articles and experimental with some formulas but I'm afraid I'm still Acrobat illiterate.  Any ideas?  Thanks.

    It would be best if you set up the Date1 field to be formatted as a date. That way, Acrobat uses a built-in routine to automatically validate that the entry represents a valid date. You can then use a custom Calculate script for the Date2 field that looks someting like:
    // Custom Calculate script for text field
    (function () {
        // Get Date1 field value
        var v = getField("Date1").value;
        // If field is empty, blank this field
        if (v === "") {
            event.value = v;
            return;
        // Convert the date string to a date object
        var d = util.scand("mm/dd/yyyy", v);
        // Subtract 5 days
        d.setDate(d.getDate() - 5);
        // Set this field's value
        event.value = util.printd("mm/dd/yyyy", d);
    Change the date format (mm/dd/yyyy) in the code above to match what you want to use.

  • Can I create a field that calculates number of days from a date field?

    Hi all,
    I need a field that will calculate the number of days elapsed whatever date is entered into the date field, and update that number of days based on the calendar/computer calendar date.  Does that make sense?
    https://www.dropbox.com/s/arkmnsxjkl4r156/AFBS_FacilitySpecialCareList02.pdf
    I set up the form so that my boss can add or subtract clients from the list.  Each client needs to have its own "Days since added to the list" number. Sorta like a little aging report.
    Is this possible?
    Many thanks,
    Laura

    Wow, I'm so stumped.  I tried to copy a bit of formcalc into the exit event for my current date field to try to make this happen, but I can't get it to work.
    My  attempt at scripting is embarrassing, but here it is:
    form1.sf1.CCSub.CCGroup.#subform[0].DateField2::exit - (FormCalc, client)
    form1.sf1.CCSub.CCGroup.#subform[0].NumericField2.rawValue = Date2Num(DateField1, "MM-DD-YY") - Date2Num(DateField2, "MM-DD-YY")
    and here's the file:
    https://www.dropbox.com/s/arkmnsxjkl4r156/AFBS_FacilitySpecialCareList02.pdf
    Can anyone help me get this right?
    Sign me: One Lost Designer
    Thanks!

  • Subtract days from given date

    hi,
    Is there any FM which will subtract the no of days from a given date.
    I hv tried with SUBTRACT_TIME_FROM_DATE , but having some config issue. And it is not available in 3.1H version.
    Some one can help me out...
    Thanks,
    shiva

    Hi,
    use the FM RP_CALC_DATE_IN_INTERVAL
    and check the sample output.
    Import parameters               Value             
    DATE                            10/10/2004        
    DAYS                            05                
    MONTHS                          00                
    SIGNUM                          +                 
    YEARS                           00                                                                               
    Export parameters               Value             
    CALC_DATE                       10/15/2004  
    Regards
    vijay

  • Deducting days from a date

    How do I deduct a specified no. of days from a datestring.
    I need to be able to get the date 30 days from a specific date for example :
    6/5/2003 given date
    less 30 days
    5/6/2003 is the date that i need

    import java.util.*;
    public class TodayMinus30
         public static void main(String[] args)     
              Calendar clCalendar = Calendar.getInstance();
              clCalendar.add(Calendar.DATE, -30);
              Date myDate = clCalendar.getTime();
              System.out.println(myDate.toString());
    }

  • Get the date of a particular week day from given date

    I have a given date.
    from that date i want to get the date of sunday of that week
    wat is the best possible way to do the same.
    for eg:
    if i am given 03/11/2007 which is a saturday
    i want to get 27/10/2007 which is the sunday which falls in the same week as of 03/11/2007
    can anybody please help.

    hi,
    Here I am posting code for your requirement.
    Here I am hard coding the date value.
    import java.util.*;
    public class DateTest{
         public static void main(String ar[]){
              Calendar calendar =new GregorianCalendar(2007,7,4);
              System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));
              calendar.set(2007,7,4-calendar.get(Calendar.DAY_OF_WEEK)+1);
              System.out.println("DAY_OF_MONTH: " + calendar.get(Calendar.DAY_OF_MONTH));
              System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
    }

  • Execute SQL Task does not Update from a Date Variable Reliably

    I'm using a DateTime variable in SSIS 2008 that is used to set the SQLStatement property of an Execute SQL Task.
    "DELETE FROM Labor WHERE Week = '" + (DT_WSTR, 100) @[User::Week] + "'"
    Week is the next Sunday:
    DATEADD( "day", @[User::DaysTillSunday] , @[User::TheDayThatIsTwentyMinutesPrior] )
    DaysTillSunday:
    DATEPART( "dw", @[User::TheDayThatIsTwentyMinutesPrior] ) == 1 ? 0 : 8 - DATEPART( "dw", @[User::TheDayThatIsTwentyMinutesPrior] )
    TheDayThatIsTwentyMinutesPrior:
    (DT_DATE)(DT_DBDATE)DATEADD("minute",-20,GETDATE())
    The SSIS Package deletes the current week's data, reloads it with fresh data, then calculates the difference between the current week and last week.
    The problem is that randomly, instead of deleting the current week, it will delete the previous week.  This happens maybe 5-10% of the time.  At least it does until I rebuild the package and import it into SQL Server again.
    I'm guessing that the Execute SQL Task is not updating the value of the Week variable before it executes.  I started with the source type being a variable.  Then I decided to try Direct input and pass in the Week as a parameter (OLE DB Connection
    Type).  That didn't work either.
    Most recently I tried writing the Week variable to a table first, then having a sequence container with all the tasks second.  Slightly better but I still saw the date was wrong 2 times in about 90 executions.  I was hoping that writing the Week
    variable out to the database would force an update of any associated connections to it, but that didn't seem to work.
    Any ideas?  Is this a known issue, am I missing a setting?
    thanks,
    John

    John, computers either work all the time or have a bug. I suspect it is the latter.
    To find it [faster] you need to log what the resulting expression was used in the package.
    I am baffled how rebuilding a package would fix anything like setting a date.
    It might be even dependant on when you run the package.
    Why
    DATEADD("minute",-20,GETDATE())
    DATEADD( "day", -8 , GETDATE() )
    It must be enough to set the week (that appears to be a date) as above.
    Arthur
    MyBlog
    Twitter

  • Extract a year from a date

    I have a date
     [Period Closed].[Period Closed] in a cube. This table contain only one values which might be  a certain date. Not today's date.
    I have another date table where I have to use the date value from [Period Closed].[Period Closed]  and pass in to another date table so that I can drive off all my data based on the date value. There is no hierarchy in [Period Closed].[Period
    Closed]  table. How can I extract year and month from [Period Closed].[Period Closed]  so that I can pass to main date table.

    Try something like this:
    StrToMember('[Other Date].[Other
    Date]&[' + Format(CDate([Period
    Closed].[Period Closed]), 'yyyyMMdd') + ']')
    This assumes that the key for [Other
    Date].[Other Date]
    is an integer with YYYYMMDD.
    Hope this helps.
    Reeves
    Denver, CO

Maybe you are looking for

  • Have a asa5505, not sure is its the right product.

    Greetings, I have a ASA5505(base model) that my sales rep said would do what I need, but after trying to set it up I think I either need upgrades or a different product. Allow me to explain what I'm trying to do and then hopefully someone will be abl

  • Using Toplink with Servlets in a Clustered application server

    I am having some problems with Toplink. Basically, I have a collection of HttpServlets that manipulate a domain object and its various collections of objects. The general technique is to place the domain object in the HttpSession, and have each Servl

  • How to use report designer using bex analyser  give screenshots  details

    how to use report designer using bex analyser  give screenshots  details

  • Check ztable in ME21N create purchase order

    Hi, I maintain one ztable for price comparision ( comparative statement) is completed or not for particular RFQ Collective. if price comparision completed when Flag 'C' is updated in ztable for that particular Collective No. So, my requirement  is :

  • Printer Setup Utility

    can't be found> "either disabled or not installed" . I've been printing >printer is recognized by computer > using about a week and needed to stop a 'job', there was no printer Icon in the dock (seems like there was before?), not able to create icon.