Get the number of days, months and year

Hi all

I'm using OBIEE 11 g. I have a line of dash for year (2010, 2011, etc.) and months (Jan, Feb,..., Dec). How can I get the number of days in a given month and year in my report?

For example, if I choose to Jan & 2011, I'd get 31 and 356. And if I choose Feb & 2011, I would get 28 and 356.

Thank you!

I have something more good option here... Try to use this

DAYOFMONTH (TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH (CURRENT_DATE) *-1, TIMESTAMPADD (SQL_TSI_MONTH, 1, CURRENT_DATE)))

This will give you the days for the month in progress (Oct 2011) after calculating the last day of each month... Similary dynamically pass the value Date or month... You will need to modify this function but shud be simple. Hope this helps :)

Tags: Business Intelligence

Similar Questions

  • Get the number of days in a month based on the month and year of fields

    I have a column in my form which lists the days in a month. I want to configure a hidden field that calculates the total number of days in a month, based on the month and year of the field inputs. The number of days will determine what appears on the column. For example, if I put 4 months, and 2016 in the field of the year, I get 30 in the hidden field. Thus, on the column 'Day', I'll have numbers 1-30. Or if I put 2 months and 2016 in the field of the year, I get the 29 in the hidden field. If the numbers 1-29 appears in the column 'day '.

    Found this on some forum javascript code:

    //Month is 1 based
    function daysInMonth(month,year) {
      
    return new Date(year, month, 0).getDate();
    }

    //July
    daysInMonth
    (7,2009); //31
    //February
    daysInMonth
    (2,2009); //28
    daysInMonth
    (2,2008); //29

    I do not know how to convert this code in JavaScript to adobe and don't really know how to use it. All I know how to do is to configure the field values for the field month and year as variables. I am a novice programmer and would appreciate it really all the help I can get. Thank you in advance!

    The code seems to be JavaScript and runs as needed by using the JavaScript console.

    I would like to consider making more general code, so if you have a date string that includes at least the month and year we could just call the function and get the number of days for that month.

    The following script will calculate the number of days in a month, by using at least the month and year values can display the result on the JavaScript console and all of the value field for the field that has this code as the custom calculation Script.

    function daysInMonth (oDate) {}
    return new Date (oDate.getFullYear (), oDate.getMonth () + 1, 0) .getDate ();
    }

    nMonth var = this.getField("Month").valueAsString; get the value of month;
    nYear var = this.getField("Year").valueAsString; get the value of the year;

    Event.Value = "";

    If (nMonth! = "" & nYear!) = "") {}
    var MyDate = util.scand ("' / mm/yyyy ', nMonth +" / "+ nYear); convert to date object;
    var nDaysInMonth = daysInMonth (MyDate); get the number of days;

    Console.Open (); Open the JavaScript console;

    Console.clear(); clear the console;

    Console.println ("Days in" + nMonth + ":" + nDaysInMonth); show days in month;

    Event.Value = nDaysInMonth; Set the value of the field;

    }

  • I want to collect rain for the day, month and year; Can what formula I use?

    I want to collect rain for the day, month and year; What formula or expression that I can use.

    I use a Rain Wise product that converts impulses to an analog value.  The rain wise device can be

    "the value measure up to 1", 5", or 10".  I will be setting the unit at 10 inches in increments of 0.01 inch.

    What I would do is at each time increments of signal I would consider it as 0.01 then after reaching

    a period of time a day or a month, back to zero.

    Need some advice on this problem.

    How about you, using a counter to count the number of times where the signal is less than 0.01?

    For example,.

    Counter.Count = signal<=>

    The total number of rain is

    Counter * 10 + signal

    Use TimeOfDay or TimeOfWeek to reset the counter.

  • Set the calendar to display day, month and year

    In addition to the time of day, my computer began giving the day of the week (Monday) only instead of day, month and year as it did before. Tried to go back to 29/12/2014 or something similar without success.  Any suggestions?

    Hello

    Sorry for the late reply and I appreciate your patience.

    User profile corruption might have caused the problem. As a solution, I suggest to create a new user profile and check if the date format displays the same thing.

    To do this, see the link below.

    http://Windows.Microsoft.com/en-us/Windows/fix-corrupted-user-profile#1TC=Windows-7.

    It will be useful. Just answer us with the State, and we will be happy to help you.

  • How to get the number of days in a month of belonging to a range of dates

    Hi, I'm going crazy around a problem, I have 2 dates and one month I wanto to retrieve the number of days belonging to the months that fall within the range.

    for example:

    month of January 2011. begin_date = January 11, 2011, May 30, 2011 end_date result is 21
    month of January 2011. begin_date = December 11, 2010, result of end_date, January 10, 2011 10
    month January 2011 .begin_date = 2 February 2011, end_date may 25, 2011 result 0
    month of January 2011. begin_date = January 3, 2011, January 5, 2011 result DATE END 3

    and so on...

    I appreciate any suggestion
    Thank you


    Andrea

    Something like that... ?

    SQL> with t as
      2  (select  to_date('11/01/11','dd/mm/yy') from_dt,
      3           to_date('30/05/11','dd/mm/yy') to_dt,
      4           'Jan-11' mnth from dual)
      5  select least(last_day(to_date(mnth,'Mon-yy')),to_dt) -
      6         greatest(to_date(mnth,'Mon-yy'),from_dt) cnt
      7  from t  ;
    
           CNT
    ----------
            20
    

    If 0 is also expected...

    SQL> with t as
      2  (select  to_date('11/01/11','dd/mm/yy') from_dt,
      3           to_date('30/05/11','dd/mm/yy') to_dt,
      4           'Jan-11' mnth from dual union all
      5           select  to_date('11/01/11','dd/mm/yy') from_dt,
      6           to_date('30/05/11','dd/mm/yy') to_dt,
      7           'Jan-12' mnth from dual
      8           )
      9  select from_dt,to_dt,mnth,
     10         greatest(
     11              least(last_day(to_date(mnth,'Mon-yy')),to_dt)
     12              -
     13              greatest(to_date(mnth,'Mon-yy'),from_dt)
     14                 ,0) cnt
     15  from t;
    
    FROM_DT   TO_DT     MNTH          CNT
    --------- --------- ------ ----------
    11-JAN-11 30-MAY-11 Jan-11         20
    11-JAN-11 30-MAY-11 Jan-12          0
    

    Published by: JAC on February 9, 2012 19:22

  • Compare and get the number of days since the same date field

    Hello

    I need to get the results in days when comparing the same field, date

    For example,.

    Primary_key_field Date_field
    100000002 1 January 10
    100000004 February 1st, 10
    100000005 30 April 10
    100000006 April 18, 10
    100000007 29 April 10
    100000008 May 1st, 10

    extract the first two date_field records based on the primary_key_field. (January 1, 2010 and February 1, 2010) and compare and find the difference and who appear in number of days, the same fetch two disks and do the same math... How can I achieve this... is it possible to make the SQL thro? Please help me solve this problem...

    Thank you and best regards,
    KBG.

    This is the query using functions oracle Analytics

    Primary_key_field Date_field
    100000002 1 January 10
    100000004 February 1st, 10
    100000005 30 April 10
    100000006 April 18, 10
    100000007 29 April 10
    100000008 May 1st, 10

    Select rn, date_field, next, next - date_field "Diff".
    de)
    ROW_NUMBER() SELECT over (ORDER BY primary_key_field) rn,
    date_field, LEAD (date_field) OVER (ORDER BY date_field) next
    FROM table_name)
    /

  • split with day, month and year in a date

    Hi all

    I have this point of view

    with (id, dt) t (select 1, to_date('02/06/2010','MM/DD/YYYY') of all the double union)
    Select 2, to_date('11/29/2001','MM/DD/YYYY') of all the double union
    Select 3, to_date('02/06/2011','MM/DD/YYYY') of all the double union
    Select option 4, double to_date('10/10/2011','MM/DD/YYYY')
    )
    --
    -end of test data
    --
    SELECT id, dt
    floor (months_between(sysdate,dt)/12) years
    , floor (mod (months_between (sysdate, dt), 12)) months
    -The day is ambiguous because of the number of days in a different month
    -you could design your own algorithm to give the desired results, but it is a good approximation
    , floor (sysdate-(add_months (dt, floor (months_between (sysdate, dt))) as dys
    t
    /
    ID DT YEARS MONTHS DYS
    ---------- ----------- ---------- ---------- ----------
    1-6 FEBRUARY 2010 5 8 22
    2 29 NOVEMBER 2001 13 10 29
    3-6 FEBRUARY 2011 4 8 22
    4-10 OCTOBER 2011 4 0 18

    As a result, 26 years old, 26 months, 91 days.


    And subtract years, MONTHS and DYS as format

    erase years, from 1 to 12 months and the days of the 1 to 30 as

    91 days = 30 x 3 + 1 = > 1 day over 3 months

    26 months + 3 months = 29 months = > 24 months + 5 months = 2 years + 5 months

    and 26 years + 2 years = 28

    desire to result: 28 years, 5 months and 1 day.

    Is there a function that give me this result from the query above?

    Kind regards

    Gordan

    Hello Gordan,.

    I understand that you are the SUM of all the lines.

    Here are two ideas:

    -1 - using a date
    (a) SUM (TRUNC (sysdate) - dt)
    I would give you the total number of days.
    (b) adding the number of days to, for example, DATE ' 1900-01-01' would give another date...
    (c) simply subtract the years 1900 and it takes several years,
    subtract 1 from the month (1-12 from January to December) and you have the number of months
    subtract 1 from the day of the month (1-31) and you have the number of days.
    It is of course 'approximate' as the months do not have the same number of days...

    -2 - using only the number of days
    Maybe you want something else, for example: the total number of days divided by 365.25 for many years, the recall divided by 30 to get the number of months, the reminder being the number of days.

    (a) SUM (TRUNC (sysdate) - dt)

    I would give you the total number of days.

    (b) Division by 365.25 (le.25 is to take leap years into account, but you can choose for example "365")

    (c) number of reminder of days (total - years * 365.25): divided by 30 is the number of months

    (d) number reminder of days (total - years * 365.25 - months * 30): gives the number of days.

    The following two options with your test data (by chance, this gives the same result in this case)

    option 1:
    with (id, dt) t (select 1, to_date('02/06/2010','MM/DD/YYYY') of all the double union)
    Select 2, to_date('11/29/2001','MM/DD/YYYY') of all the double union
    Select 3, to_date('02/06/2011','MM/DD/YYYY') of all the double union
    Select option 4, double to_date('10/10/2011','MM/DD/YYYY')
    )
    target_date AS
    (SELECT DATE ' 1900-01-01' + SUM (TRUNC (sysdate) - t.dt) FROM t trgt)
    in_pieces AS
    (SELECT TO_NUMBER (TO_CHAR (td.trgt, 'YYYY')) - 1900 y
    , TO_NUMBER (TO_CHAR (td.trgt, 'MM')) - 1 m
    , TO_NUMBER (TO_CHAR (td.trgt, 'DD')) - 1 d
    Target_date TD
    )
    SELECT "result: ' |"
    TRIM (CASE WHEN ip.y = 0 THEN NULL
    WHEN ip.y = 1 THEN "1 year"
    Of OTHER TO_CHAR (ip.y) | "years".
    END |
    CASE WHEN ip.m = 0 THEN NULL
    WHEN ip.m = 1 THEN "1 month"
    Of OTHER TO_CHAR (ip.m) | 'months '.
    END |
    CASE WHEN ip.d = 0 THEN NULL
    WHEN ip.d = 1 THEN "1 day"
    Of OTHER TO_CHAR (ip.d) | 'days '.
    END
    )
    Of in_pieces ip
    ;
    result: 28 years, 4 months and 28 days

    option 2:

    with (id, dt) t (select 1, to_date('02/06/2010','MM/DD/YYYY') of all the double union)
    Select 2, to_date('11/29/2001','MM/DD/YYYY') of all the double union
    Select 3, to_date('02/06/2011','MM/DD/YYYY') of all the double union
    Select option 4, double to_date('10/10/2011','MM/DD/YYYY')
    )
    nb_days AS
    (SELECT SUM (TRUNC (sysdate) - t.dt) n t)
    , y AS
    (SELECT Nb.n, FLOOR (nb.n / 365.25) y nb_days n. b.)
    ym AS
    (SELECT y.n, y.y, FLOOR ((y.n-y.y * 365,25) / 30) FROM a)
    ymd AS
    (SELECT ym.y, ym.m, ym.n - ym.y * 365.25 - ym.m * ym FROM 30 d)
    SELECT "result: ' |"
    TRIM (CASE WHEN ymd.y = 0 THEN NULL
    WHEN ymd.y = 1 THEN "1 year"
    Of OTHER TO_CHAR (ymd.y) | "years".
    END |
    CASE WHEN ymd.m = 0 THEN NULL
    WHEN ymd.m = 1 THEN "1 month"
    Of OTHER TO_CHAR (ymd.m) | 'months '.
    END |
    CASE WHEN ymd.d = 0 THEN NULL
    WHEN ymd.d = 1 THEN "1 day"
    Of OTHER TO_CHAR (ymd.d) | 'days '.
    END
    )
    WAN
    ;
    result: 28 years, 4 months and 28 days

    Best regards

    Bruno Vroman.

  • SQL query to get the number of days monthwise

    Hello
    I'm new to sql, can someone please tell me query to find the number of days between the two dates months wise.
    say
    FIRSTDATE last date
    21/03/2011-25/06/2011

    March April May June
    9 22 23 18

    Hello

    Welcome to the forum!

    Here's one way:

    WITH     all_dates     AS
    (
         SELECT     start_date + LEVEL - 1     AS a_date
         FROM     (
                   SELECT     TO_DATE ('21/03/2011', 'DD/MM/YYYY')     AS start_date
                   ,     TO_DATE ('25/06/2011', 'DD/MM/YYYY')     AS end_date
                   FROM     dual
              )
         CONNECT BY     LEVEL     <= end_date + 1 - start_date
    )
    SELECT       TO_CHAR ( TRUNC (a_date, 'MONTH')
                , 'fmMonth YYYY'
                )               AS month
    ,       COUNT (*)               AS num_days
    FROM       all_dates
    WHERE       a_date - TRUNC (a_date, 'IW')     < 5
    GROUP BY  TRUNC (a_date, 'MONTH')
    ORDER BY  TRUNC (a_date, 'MONTH')
    ;
    

    What is a 'working day '? I guess you mean every day except Saturday or Sunday, but the query aboveare sometimes figures less than you have asked:

    MONTH             NUM_DAYS
    --------------- ----------
    March 2011               9
    April 2011              21
    May 2011                22
    June 2011               18
    

    Are a few days working on Saturday or Sunday? How do you get the 22 working days in April 2011 and 23 in may?

    SQL is good at obtaining results with a variable number of rows, but you have to say exactly the desired number of columns when you write the query.
    If you really need the output of the way you said, with any number of columns, then watch in swing or a grouping of the chain . See the FAQ forum
    https://forums.Oracle.com/forums/Ann.jspa?annID=1535
    "4. How can I convert rows to columns.

  • How to get the number of days

    Hai bloggers,
    See us have 365 days a year for all first half we'll have 180 + days (if we choose first half as the guest and we select week as guest number and the last date of this particular week must indicate in the report) and the number of days until this date or a week should also display... If we choose the second half and half week number it should show number of days until this week and more Date of this issue of the day week should be from 1 to 180 + only way (July 1 m is 1)

    Thank you

    You must use the timestampdiff function to calculate the number of days. One of the way to calculate is how

    cases where "Time". "" Calendar semester "= 1 then timestampdiff (SQL_TSI_DAY, CAST (EVALUATE ('TO_DATE (%1, %2)','' 01-01 |' @{YEAR} {2010}',"DD-MM-YYYY") AS DATE), cast OFF (EVALUATE ('TO_DATE' (1%, 2%), 30-06' |' @{YEAR} {2010}',"DD-MM-YYYY") AS DATE)) else timestampdiff (SQL_TSI_DAY, MOUNT (EVALUATE ('TO_DATE (%1, %2)','01-07' |' @{YEAR} {2010}',"DD-MM-YYYY") AS DATE), cast OFF (EVALUATE ('TO_DATE' (1%, 2%),' 31-12 |' @{YEAR} {2010}',"DD-MM-YYYY") AS DATE)) end

    If you want to calculate between the 1st day of the half and the last date a week then after

    cases where "Time". ' ' Calendar semester ' = 1 then timestampdiff (SQL_TSI_DAY, CAST (EVALUATE ('TO_DATE (%1, %2)','01-01' |' @{YEAR} {2010}', 'DD-MM-YYYY') AS DATE), MAX (MAX ("Time".) "Calendar Date"))) else timestampdiff (SQL_TSI_DAY, CAST (EVALUATE ('TO_DATE (%1, %2)','01-07' |' @{YEAR} {2010}', 'DD-MM-YYYY') AS the DATE), MAX (MAX ("Time".) " End Calendar Date")))

    Hope that it will answer your question

    Thank you
    Phani.

  • get the number of days of the week to sysdate

    Hi all

    my need is to get the number of the day of the week of sysdate.

    Here's how can I make it right now:

    Select to_char(sysdate,'Dy') t1 double

    But he returns the abbreviated name of the day of the week while I need number of days of the week.

    Please help me. Thanks in advance.

    Best regards

    --

    Marco

    Or if you want the ISO week (Monday = day 1):

    Select trunc (sysdate) - trunc(sysdate,'IW') + 1 double;

  • Manage the values of the actual day, month and year

    Hello

    I am trying to enter digital variables the same day (format: 1 / 10), month (format: 1 / 10) and year (format: 1900). I tried to use this sample:

    "< mx:DateFormatter id ="DDformatter"formatString ="DD"/ > "

    "< mx:DateFormatter id ="MMformatter"formatString ="MM"/ >"

    "< mx:DateFormatter id ="YYYYformatter"formatString ="YYYY"/ >"

    In the Script:

    private var actualDate: Date = new Date();

    [Bindable] private var actualDay:String = DDformatter(actualDate) .format.

    [Bindable] private var actualMonth:String = MMformatter(actualDate) .format.

    [Bindable] private var actualYear:String = YYYYformatter(actualDate) .format.

    Part of getting an error when I run my application (am I missing some import?) I would like to have these data in numerical variables:

    #1009 error - cannot access a property or method of a null object reference.

    Pls find the solution of your problem... Let me know if you have any problem.

    MainApplication.mxml

    http://www.Adobe.com/2006/mxml '.

    layout = "absolute" creationComplete = "onCreationComplete ()" > "

    private var actualDate:Date = new Date();

    [Bindable]

    private var actualDay:String;

    [Bindable]

    private var actualMonth:String;

    [Bindable]

    private var actualYear:String;

    private function onCreationComplete():void

    {

    actualDay = DDformatter.format (actualDate);

    actualMonth = MMformatter.format (actualDate);

    actualYear = YYYYformatter.format (actualDate);

    }

    ]]>

    with respect,

    Mayeul Singh Bartwal

  • Function to return the number of days in a month?

    In one of my rules, I need to allocate an amount of benefits based on the number of days remaining in the calendar month.

    OPM does have a function that can provide me with the number of days in a calendar month?

    Thank you very much
    Isamu

    It is not a direct function to do this, however, it can be done with a bit of messing around. The following rules you will get the number of days of the month of the date of the date

    Basically, you get the first day of the month, add a month to the first day of the following month and then get the number of days between them, which will give you the number of days of the month of the date

    the month = ExtractMonth(the date)
    the year = ExtractYear(the date)
    the start of the month =MakeDate(the year, the month, 1)
    the start of the next month = AddMonths(the start of the month, 1)
    The number of days in the month = DayDifference(the start of the month, the start of the next month)
    

    These rules can be a little more compact, but it is basically how to do it.

  • Calculate fees that pay based on the number of days in a month

    Hello

    I'm writing the BR to fresh wages, based on the number of days in the month.

    Fix(Jan:DEC)

    "Salary" = ("Annual salary"-> "BegBalance" / 12) * "workforce";

    The existing calculation was ' wages divided by months no .of (12) ", now instead of number months wages that need to be calculated ("BegBalance"/ No..) OF DAYS IN THE MONTH) * 12.

    Can someone pls guide me, how to begin writing the BR for 'No. DAYS OF THE MONTH.

    You can do an admin enter number of days in the month. I remember CL reminding me the rhyme thirty days has September - Wikipedia, the free encyclopedia

    Jokes aside, you can use SQL to get the number of days. You will get different options for SQL and Oracle.

    If you want to continue to do this in BR then

    Fix(Jan:DEC)

    IF (@ISMBR (SEP) OR @ISMBR (Apr) OR @ISMBR (Jun) OR @ISMBR (Nov))

    ("Salary" = ("annual salary"-> "BegBalance" / 30) * 12) * "workforce";

    ELSEIF (@ISMBR (Jan) OR @ISMBR (Mar) OR @ISMBR (May) OR @ISMBR (July) OR @ISMBR (Aug))

    ("Salary" = ("annual salary"-> "BegBalance" / 31) * 12) * "workforce";

    ELSE (@ISMBR (Feb))

    IF (@Remainder($CurrYr/4) == 0)

    ("Salary" = ("annual salary"-> "BegBalance" / 29) * 12) * "workforce";

    ON THE OTHER

    ("Salary" = ("annual salary"-> "BegBalance" / 28) * 12) * "workforce";

    ENDIF

    ENDIF

    ENDFIX

    Concerning

    Celvin

    http://www.orahyplabs.com

    Post edited by: CelvinKattookaran

  • Count of the number of days in a calendar month according to the year

    Hi all

    On my table, column 1 is the list of months over several years.

    Column 2 is the activity number od each month.

    Column 3 I want an average rate of activity per day during the month, which should be: (C2 / number of days according to C1) %

    Problem: I can't find a fomula give me the number of days, particularly in February when the year is leap.

    Any help is appreciated.

    Thank you all,

    Lopez

    PS: by the way, with this new version of Apple Comunity I seem to have lost my previous questions about the numbers.

    Hey Lopez,

    EOMONTH(A1,0) (end of month) will GET help you.

    Column B is Date & time format to display only the month and year (actually the 1st of the month, but the day is not displayed).

    Formula in C2 (fill down)

    = EOMONTH(B2,0)

    The end of the month 0 months later.

    Formula in D2 (fill down)

    = DAY (C2)

    February 2015 (non-leap years) shows 28

    February 2016 (leap year) shows 29

    Kind regards

    Ian.

  • Gets the number of records in the report based on the input of the user on the date and the number of days.

    Hello

    I need where there are quick dashboard that selects the date, second interval column consists of >, <, = and the third column is seen number (in days)

    for example, the user enters: 12 18, 2015, <, 9. here I report who should get the data (records) 9 days earlier from the date specified (from 12/10/2015 to 18/12/2015).

    Similarly for > =.

    How to get there. I'm unable to write the script and I use the column date in my report. Ask that you please advice how to solve this problem.

    Please find below the screen for reference.

    timediff.jpg

    Kind regards

    Chandra Khalil.

    Hello

    Not exactly why you're doing the report this way. If the user must select, basically, a period of dates, would not easier to have a column of data with a between the operator and the user would select 2 dates (upper and lower intervals)?

    In any case, it is possible to achieve what you want to do as a result of your approach. You could use when's CASE and have a more complex filter, but I think that it is better to have a few nested filters where you use the range operator to determine what date filter that you use (see image below)

    Some notes about my filter. First of all, I am making the assumption that the operator is "=", then the number of days specified must be ignored and you just return the data for the selected date. You will notice also that in my filters, I got a cast so far, but if you are using a column that is already a timestamp so it won't be necessary.

    This should achieve what you want.

    See you soon,.

    Pedro

Maybe you are looking for