How to get min date of every month for six months?

Hi, i have data like this.
Process_date SEQ_No
16-MAR-13     733
09-MAR-13     732
02-MAR-13     731
24-FEB-13     730
16-FEB-13     728
09-FEB-13     727
02-FEB-13     726
26-JAN-13     725
21-JAN-13     724
12-JAN-13     723
05-JAN-13     722
29-DEC-12     721
24-DEC-12     720
15-DEC-12     719
08-DEC-12     718
03-DEC-12     717
22-NOV-12     716
17-NOV-12     715
10-NOV-12     714
03-NOV-12     713
29-OCT-12     712
23-OCT-12     711
13-OCT-12     710
05-OCT-12     709
28-SEP-12     708
22-SEP-12     707
15-SEP-12     706
08-SEP-12     705
01-SEP-12     704
everymonth admin will refresh actual data table and automatically this above table will update with unique seq_no and process_date.
I need to extarct min date of everymonth(First refresh of last 6 months - excluding currrent month) and also seq_no related to that month so using joins(using seq_no - that is available in main table) i can combine actual data.
I need result like:
02-MAR-13     731 ( I don't need MAR as it should not take current month data)
so i need final result like below:
02-FEB-13     726
05-JAN-13     722
08-DEC-12     718
03-NOV-12     713
05-OCT-12     709
01-SEP-12     704

995263 wrote:
Hi, i have data like this.
Process_date SEQ_No
16-MAR-13     733
09-MAR-13     732
02-MAR-13     731
24-FEB-13     730
16-FEB-13     728
09-FEB-13     727
02-FEB-13     726
26-JAN-13     725
21-JAN-13     724
12-JAN-13     723
05-JAN-13     722
29-DEC-12     721
24-DEC-12     720
15-DEC-12     719
08-DEC-12     718
03-DEC-12     717
22-NOV-12     716
17-NOV-12     715
10-NOV-12     714
03-NOV-12     713
29-OCT-12     712
23-OCT-12     711
13-OCT-12     710
05-OCT-12     709
28-SEP-12     708
22-SEP-12     707
15-SEP-12     706
08-SEP-12     705
01-SEP-12     704
everymonth admin will refresh actual data table and automatically this above table will update with unique seq_no and process_date.
I need to extarct min date of everymonth(First refresh of last 6 months - excluding currrent month) and also seq_no related to that month so using joins(using seq_no - that is available in main table) i can combine actual data.
I need result like:
02-MAR-13     731 ( I don't need MAR as it should not take current month data)
so i need final result like below:
02-FEB-13     726
05-JAN-13     722
*08-DEC-12     718 (why??? if we have 03-DEC-12     717)*
03-NOV-12     713
05-OCT-12     709
01-SEP-12     704i think you want something like this:
WITH T(d,s) AS
select to_date('16-MAR-13','dd-MON-yy'),733 from dual union all
select to_date('09-MAR-13','dd-MON-yy'),732 from dual union all
select to_date('02-MAR-13','dd-MON-yy'),731 from dual union all
select to_date('24-FEB-13','dd-MON-yy'),730 from dual union all
select to_date('16-FEB-13','dd-MON-yy'),728 from dual union all
select to_date('09-FEB-13','dd-MON-yy'),727 from dual union all
select to_date('02-FEB-13','dd-MON-yy'),726 from dual union all
select to_date('26-JAN-13','dd-MON-yy'),725 from dual union all
select to_date('21-JAN-13','dd-MON-yy'),724 from dual union all
select to_date('12-JAN-13','dd-MON-yy'),723 from dual union all
select to_date('05-JAN-13','dd-MON-yy'),722 from dual union all
select to_date('29-DEC-12','dd-MON-yy'),721 from dual union all
select to_date('24-DEC-12','dd-MON-yy'),720 from dual union all
select to_date('15-DEC-12','dd-MON-yy'),719 from dual union all
select to_date('08-DEC-12','dd-MON-yy'),718 from dual union all
select to_date('03-DEC-12','dd-MON-yy'),717 from dual union all
select to_date('22-NOV-12','dd-MON-yy'),716 from dual union all
select to_date('17-NOV-12','dd-MON-yy'),715 from dual union all
select to_date('10-NOV-12','dd-MON-yy'),714 from dual union all
select to_date('03-NOV-12','dd-MON-yy'),713 from dual union all
select to_date('29-OCT-12','dd-MON-yy'),712 from dual union all
select to_date('23-OCT-12','dd-MON-yy'),711 from dual union all
select to_date('13-OCT-12','dd-MON-yy'),710 from dual union all
select to_date('05-OCT-12','dd-MON-yy'),709 from dual union all
select to_date('28-SEP-12','dd-MON-yy'),708 from dual union all
select to_date('22-SEP-12','dd-MON-yy'),707 from dual union all
select to_date('15-SEP-12','dd-MON-yy'),706 from dual union all
select to_date('08-SEP-12','dd-MON-yy'),705 from dual union all
select to_date('01-SEP-12','dd-MON-yy'),704 from dual
SELECT MIN(D),
       MIN(S) KEEP(DENSE_RANK FIRST ORDER BY D)
  FROM (SELECT D,
               S,
               TO_CHAR(D, 'mm') M,
               TO_CHAR(D, 'yy') Y,
               DENSE_RANK() OVER(ORDER BY TO_CHAR(D, 'yy') || TO_CHAR(D, 'mm') DESC) RN
          FROM T)
WHERE RN BETWEEN 2 AND 7
GROUP BY M, Y
ORDER BY 1 DESC

Similar Messages

  • How to get the data from pcl2 cluster for TCRT table.

    Hi frndz,
    How to get the data from pcl2 cluster for tcrt table for us payroll.
    Thanks in advance.
    Harisumanth.Ch

    PL take a look at the sample Program EXAMPLE_PNP_GET_PAYROLL in your system. There are numerous other ways to read payroll results.. Pl use the search forum option & you sure will get a lot of hits..
    ~Suresh

  • How to get / configure data in Tcode "MCTG" for "SIS: Sales Office Analysis Selection "?

    Hello SAP Guru's,
    How to get / configure data in Tcode "MCTG" for "SIS: Sales Office Analysis Selection "? We have implemented SAP ECC 6.0 EHP4 version in the organization. If anybody have any idea, need help .
    Thanks in Advance.
    Prashant Kunjir

    Have a look at the following note:-
    Note 1573200 - How to restructure the statistic data of the sales information system (SIS)
    But before trying to carry out the process as detailed in the above note, first check with other SIS reports like MCTA etc., and no reports are showing correctly, then you can proceed.  Otherwise, you need to raise an OSS message with SAP.
    G. Lakshmipathi

  • Get Last date of every Month in a year

    Hi All,
    I need to find last date of month for given year.
    Example:
    I used to pass date or year such as 2012 or 01-01-2012(DD-MM-YYYY)
    SQL query needs to return last date of every month such as
    31-01-2012
    28-02-2012
    31-03-2012
    30-04-2012
    31-12-2012
    for above requirement i have written the following SQL
    select rownum as row_count,
    case when rownum=1 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as Jan_month,
    case when rownum=2 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as Feb_month,
    case when rownum=3 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as mar_month,
    case when rownum=4 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as apr_month,
    case when rownum=5 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as may_month,
    case when rownum=6 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as jun_month,
    case when rownum=7 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as jul_month,
    case when rownum=8 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as aug_month,
    case when rownum=9 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as sep_month,
    case when rownum=10 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as oct_month,
    case when rownum=11 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as nov_month,
    case when rownum=12 then last_day(to_date(add_months(trunc(to_date('01-01-2012','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end as dec_month
    from dual connect by level <= 12 order by rownum;
    Result
    Jan_Month
    Feb_Month
    Mar_Month
    Apr_Month
    may_month
    jun_month
    jul_month
    aug_month
    sep_month
    oct_month
    nov_month
    dec_month
    1
    31-01-2014
    2
    28-02-2014
    3
    31-03-2014
    4
    30-04-2014
    5
    31-05-2014
    6
    30-06-2014
    7
    31-07-2014
    8
    31-08-2014
    9
    30-09-2014
    10
    31-10-2014
    11
    30-11-2014
    12
    31-12-2012
    Excepted Result:
    am excepted result as single row such as
    Jan_Month
    Feb_Month
    Mar_Month
    Apr_Month
    may_month
    jun_month
    jul_month
    aug_month
    sep_month
    oct_month
    nov_month
    dec_month
    31-01-2012
    28-02-2012
    31-03-2012
    30-04-2012
    31-05-2012
    30-06-2012
    31-07-2012
    31-08-2012
    30-09-2012
    31-10-2012
    30-11-2012
    31-12-2012
    Kindly give me suggestion to archive above result.
    Thanks&Regards
    Sami

    I agree with Marcus Pivot is the way to go about this... But on the other hand you almost solved it yourself.. just a max function was needed for your expected output:
    select
    max(case  when rownum=1 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as Jan_month,
    max(case  when rownum=2 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as Feb_month,
    max(case  when rownum=3 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as mar_month,
    max(case  when rownum=4 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as apr_month,
    max(case  when rownum=5 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as may_month,
    max(case  when rownum=6 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as jun_month,
    max(case  when rownum=7 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as jul_month,
    max(case  when rownum=8 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as aug_month,
    max(case  when rownum=9 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as sep_month,
    max(case  when rownum=10 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as oct_month,
    max(case  when rownum=11 then last_day(to_date(add_months(trunc(to_date('01-01-2014','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as nov_month,
    max(case  when rownum=12 then last_day(to_date(add_months(trunc(to_date('01-01-2012','DD-MM-YYYY'), 'YYYY'), level - 1), 'DD-MM-YY')) end) as dec_month
    from dual connect by level <= 12 order by rownum;
    AND to avoid hardcoding you can also modify your query as :
    select
    max(case  when rownum=1 then last_day(to_date(to_char(rownum),'MM')) end) as Jan_month,
    max(case  when rownum=2 then last_day(to_date(to_char(rownum),'MM')) end) as Feb_month,
    max(case  when rownum=3 then last_day(to_date(to_char(rownum),'MM')) end) as mar_month,
    max(case  when rownum=4 then last_day(to_date(to_char(rownum),'MM')) end) as apr_month,
    max(case  when rownum=5 then last_day(to_date(to_char(rownum),'MM')) end) as may_month,
    max(case  when rownum=6 then last_day(to_date(to_char(rownum),'MM')) end) as jun_month,
    max(case  when rownum=7 then last_day(to_date(to_char(rownum),'MM')) end) as jul_month,
    max(case  when rownum=8 then last_day(to_date(to_char(rownum),'MM')) end) as aug_month,
    max(case  when rownum=9 then last_day(to_date(to_char(rownum),'MM')) end) as sep_month,
    max(case  when rownum=10 then last_day(to_date(to_char(rownum),'MM')) end) as oct_month,
    max(case  when rownum=11 then last_day(to_date(to_char(rownum),'MM')) end) as nov_month,
    max(case  when rownum=12 then last_day(to_date(to_char(rownum),'MM')) end) as dec_month
    from dual connect by level <= 12 order by rownum;
    Easy way: (without connect)
    SELECT LAST_DAY (TO_DATE (ROWNUM, 'MM')) AS Jan_month,
           LAST_DAY (TO_DATE (ROWNUM + 1, 'MM')) AS Feb_month,
           LAST_DAY (TO_DATE (ROWNUM + 2, 'MM')) AS Mar_month,
           LAST_DAY (TO_DATE (ROWNUM + 3, 'MM')) AS Apr_month,
           LAST_DAY (TO_DATE (ROWNUM + 4, 'MM')) AS May_month,
           LAST_DAY (TO_DATE (ROWNUM + 5, 'MM')) AS Jun_month,
           LAST_DAY (TO_DATE (ROWNUM + 6, 'MM')) AS Jul_month,
           LAST_DAY (TO_DATE (ROWNUM + 7, 'MM')) AS Aug_month,
           LAST_DAY (TO_DATE (ROWNUM + 8, 'MM')) AS Sep_month,
           LAST_DAY (TO_DATE (ROWNUM + 9, 'MM')) AS Oct_month,
           LAST_DAY (TO_DATE (ROWNUM + 10, 'MM')) AS Nov_month,
           LAST_DAY (TO_DATE (ROWNUM + 11, 'MM')) AS Dec_month
      FROM DUAL
    Cheers,
    Manik.

  • How to get currect date by using month and year

    hai,
    By using month like 'Jul' and year like 2007 i want to get full date like 01/06/2007(format).Please give me query for this?My fields for month and year are respectively vr_mnth(varchar) and in_year(number)

    i used to_date function but it accepts only one string .if i give like this
    to_date(vr_mnth,in_year,'dd/mm/yy') it will gives me syntax error.
    If i give like this vr_mtnh='Jan'
    to_date(vr_mtnh,'Mon') it will give output
    01/01/2008 it shows me current year
    if i choose from table wich is strored with month-'Jul' and year=2006 it shows me
    01/07/2008 only .It doesn't shows me that 2006 year
    If i give in_year in to_date it gives me that currect year.
    Ex:to_date(in_year,'YY')..............>01/01/2006
    Individually to_date function works fine but i want to club both to get accurate date format of specified month and year.Is there any function for that in sql to get 01/07/2006?

  • How to get 10th day of every month?

    Hi All,
    please find the below requirement , how to achive this?
    " Show the Actual as a bar on a monthly frequency, with Actual costs shown as they existed on the 10th business day of each month, going back six months – the Target can be shown as a line"
    Please help me out
    thanks
    Swapna

    HI ,
    implement this function in ur colum edit
    EVALUATE('TRUNC(%1,''MONTH'')+09',colmn_name)
    u wil get answer for this requirement
    regards
    srinivas

  • How to get start date of the period for a given date from cube

    I have a situation where i need to find the start day of the period for a given date. is there a way to know that. i want to use that in my report. i enter the date from my report(i have date parameter), depends on the date, i want to display the start day
    of the period. how can i write expression for that in my report?
    ram

    Hi ramprasad74,
    According to your description, you are using Analysis Services as a data source for the report, the cube has hierarchy: Fyear, FQuarter, FPeriod, fweek, Fdate. You want to add a date parameter to the report, after you changed value of the parameter, the
    report will return the first day of FPeriod.
    To achieve your goal, we need to add a parameter to the report, then use the parameter in mdx query. For detail information, please refer to the following steps:
    In the Report Data pane, right-click on a dataset created from a SQL Server Analysis Services data source type, and then click Query. The MDX query designer opens in Design mode.
    On the toolbar, click Design to toggle to Query mode.
    On the MDX query designer toolbar, click Query Parameters symbol. The Query Parameters dialog box opens.
    In the Parameter column, click <Enter Parameter>, and then type the name of a parameter.
    In the Dimension column, choose a value from the drop-down list.
    In the Hierarchy column, choose a value from the drop-down list.
    In the Default column, from the drop-down list, select a single value.
    Click OK. 
    In query designer dialog box, type the mdx query like below:
    with member [Measures].[FirstChild]
    as
    [Date].[Fiscal].currentmember.parent.firstchild.name
    select {[Measures].[FirstChild]} on 0,
    [Date].[Fiscal].[Date].members on 1
    from
    ( SELECT ( STRTOSET(@ParameterName, CONSTRAINED) ) on 0
    from
    [Cube]
    Here are relevant threads you can reference:
    https://social.msdn.microsoft.com/forums/sqlserver/en-US/c7146ac3-40ea-4d53-b321-c707aebbd405/how-to-pass-date-parameter-to-mdx-query
    https://social.msdn.microsoft.com/forums/sqlserver/en-US/fd12a865-bc90-4a65-af42-ce38a8cfa29b/pass-date-time-parameter-to-mdx-query-ssrs
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    If you have any feedback on our support, please click
    here.

  • How to get the date for the first monday of each month

    Dear Members,
    How to get the date for the first monday of each month.
    I have written the following code
    SELECT decode (to_char(trunc(sysdate+30 ,'MM'),'DAY'),'MONDAY ',trunc(sysdate+30 ,'MM'),NEXT_DAY(trunc(sysdate+30 ,'MM'), 'MON')) FROM DUAL
    But it look bith complex.
    Abhishek
    Edited by: 9999999 on Mar 8, 2013 4:30 AM

    Use IW format - it will make solution NLS independent. And all you need is truncate 7<sup>th</sup> day of each month using IW:
    select  sysdate current_date,
            trunc(trunc(sysdate,'mm') + 6,'iw') first_monday_the_month
      from  dual
    CURRENT_D FIRST_MON
    08-MAR-13 04-MAR-13
    SQL> Below is list of first monday of the month for this year:
    with t as(
              select  add_months(date '2013-1-1',level-1) dt
                from  dual
                connect by level <= 12
    select  dt first_of_the_month,
            trunc(dt + 6,'iw') first_monday_the_month
      from  t
    FIRST_OF_ FIRST_MON
    01-JAN-13 07-JAN-13
    01-FEB-13 04-FEB-13
    01-MAR-13 04-MAR-13
    01-APR-13 01-APR-13
    01-MAY-13 06-MAY-13
    01-JUN-13 03-JUN-13
    01-JUL-13 01-JUL-13
    01-AUG-13 05-AUG-13
    01-SEP-13 02-SEP-13
    01-OCT-13 07-OCT-13
    01-NOV-13 04-NOV-13
    FIRST_OF_ FIRST_MON
    01-DEC-13 02-DEC-13
    12 rows selected.
    SQL> SY.

  • How To Run Background Job on Specific Date of Every Month

    Hi,
    I am looking for an option there we can Run Background job On Specific Date!
    Example: Task Name: Zprg1 > each month of "18", and same I want to repeat after 3 Days means on "22", then want to repeat after 5 days means on "28"
    please suggest.

    Hi swapZ,
    this is very easy:
    1. Schedule the Job Zprg1 on the 18th of this month and enter a mothly period:
    2. copy this job to new name  Zprg1_plus3 and repeate the action of point 1 with the date 22.04.2015.
    3. copy this job to new name  Zprg1_plus5 and repeate the action of point 1 with the date 28.04.2015.
    You will get thre jobs running every month on 18. 22. and 28.
    Best regards
    Willi Eimler

  • Mdx query to get the last date of every month if the month is current month need current date..

    i have a scenario where i need the data of last date of every month and if the month is current month need current date data...
    is it possible using MDX...

    Hi Shashi,
    According to your description, you want to return the last day for each month except current month, right?
    In MDX, we can use ClosingPeriod function to return the member that is the last sibling among the descendants of a specified member at a specified level, here is a sample query for you reference.
    with member [measures].[a]
    as
    ClosingPeriod ([Date].[Calendar].[Date],[Date].[Calendar].currentmember).name
    select {[measures].[a]} on 0,
    [Date].[Calendar].[Month].members on 1
    from
    [Adventure Works]
    And then use the IIF function to evaluate if the month is current month. Please refer to the links below.
    http://msdn.microsoft.com/en-us/library/ms145584.aspxhttp://msdn.microsoft.com/en-IN/library/ms145994.aspx
    Regards,
    Charlie Liao
    TechNet Community Support

  • How to Get Missing Dates for Each Support Ticket In My Query?

    Hello -
    I'm really baffled as to how to get missing dates for each support ticket in my query.  I did a search for this and found several CTE's however they only provide ways to find missing dates in a date table rather than missing dates for another column
    in a table.  Let me explain a bit further here -
    I have a query which has a list of support tickets for the month of January.  Each support ticket is supposed to be updated daily by a support rep, however that isn't happening so the business wants to know for each ticket which dates have NOT been
    updated.  So, for example, I might have support ticket 44BS which was updated on 2014-01-01, 2014-01-05, 2014-01-07.  Each time the ticket is updated a new row is inserted into the table.  I need a query which will return the missing dates per
    each support ticket.
    I should also add that I DO NOT have any sort of admin nor write permissions to the database...none at all.  My team has tried and they won't give 'em.   So proposing a function or storable solution will not work.  I'm stuck with doing everything
    in a query.
    I'll try and provide some sample data as an example -
    CREATE TABLE #Tickets
    TicketNo VARCHAR(4)
    ,DateUpdated DATE
    INSERT INTO #Tickets VALUES ('44BS', '2014-01-01')
    INSERT INTO #Tickets VALUES ('44BS', '2014-01-05')
    INSERT INTO #Tickets VALUES ('44BS', '2014-01-07')
    INSERT INTO #Tickets VALUES ('32VT', '2014-01-03')
    INSERT INTO #Tickets VALUES ('32VT', '2014-01-09')
    INSERT INTO #Tickets VALUES ('32VT', '2014-01-11')
    So for ticket 44BS, I need to return the missing dates between January 1st and January 5th, again between January 5th and January 7th.  A set-based solution would be best.
    I'm sure this is easier than i'm making it.  However, after playing around for a couple of hours my head hurts and I need sleep.  If anyone can help, you'd be a job-saver :)
    Thanks!!

    CREATE TABLE #Tickets (
    TicketNo VARCHAR(4)
    ,DateUpdated DATETIME
    GO
    INSERT INTO #Tickets
    VALUES (
    '44BS'
    ,'2014-01-01'
    INSERT INTO #Tickets
    VALUES (
    '44BS'
    ,'2014-01-05'
    INSERT INTO #Tickets
    VALUES (
    '44BS'
    ,'2014-01-07'
    INSERT INTO #Tickets
    VALUES (
    '32VT'
    ,'2014-01-03'
    INSERT INTO #Tickets
    VALUES (
    '32VT'
    ,'2014-01-09'
    INSERT INTO #Tickets
    VALUES (
    '32VT'
    ,'2014-01-11'
    GO
    GO
    SELECT *
    FROM #Tickets
    GO
    GO
    CREATE TABLE #tempDist (
    NRow INT
    ,TicketNo VARCHAR(4)
    ,MinDate DATETIME
    ,MaxDate DATETIME
    GO
    CREATE TABLE #tempUnUserdDate (
    TicketNo VARCHAR(4)
    ,MissDate DATETIME
    GO
    INSERT INTO #tempDist
    SELECT Row_Number() OVER (
    ORDER BY TicketNo
    ) AS NROw
    ,TicketNo
    ,Min(DateUpdated) AS MinDate
    ,MAx(DateUpdated) AS MaxDate
    FROM #Tickets
    GROUP BY TicketNo
    SELECT *
    FROM #tempDist
    GO
    -- Get the number of rows in the looping table
    DECLARE @RowCount INT
    SET @RowCount = (
    SELECT COUNT(TicketNo)
    FROM #tempDist
    -- Declare an iterator
    DECLARE @I INT
    -- Initialize the iterator
    SET @I = 1
    -- Loop through the rows of a table @myTable
    WHILE (@I <= @RowCount)
    BEGIN
    --  Declare variables to hold the data which we get after looping each record
    DECLARE @MyDate DATETIME
    DECLARE @TicketNo VARCHAR(50)
    ,@MinDate DATETIME
    ,@MaxDate DATETIME
    -- Get the data from table and set to variables
    SELECT @TicketNo = TicketNo
    ,@MinDate = MinDate
    ,@MaxDate = MaxDate
    FROM #tempDist
    WHERE NRow = @I
    SET @MyDate = @MinDate
    WHILE @MaxDate > @MyDate
    BEGIN
    IF NOT EXISTS (
    SELECT *
    FROM #Tickets
    WHERE TicketNo = @TicketNo
    AND DateUpdated = @MyDate
    BEGIN
    INSERT INTO #tempUnUserdDate
    VALUES (
    @TicketNo
    ,@MyDate
    END
    SET @MyDate = dateadd(d, 1, @MyDate)
    END
    SET @I = @I + 1
    END
    GO
    SELECT *
    FROM #tempUnUserdDate
    GO
    GO
    DROP TABLE #tickets
    GO
    DROP TABLE #tempDist
    GO
    DROP TABLE #tempUnUserdDate
    Thanks, 
    Shridhar J Joshi 
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • How to get the Date in a particular format?

    Hi,
    How to get the Date in the below format? I will be passing the year in my method..
    2/10/2003 9:46:52 PM
    D/M/YYYY H:M:S A
    public Date getDate (String year) {
    Here i want to get the Date in this format
    2/10/<Passed Year> 9:46:52 PM
    Thanks

    This is my code
    public static Date getCalendar(Calendar calendar,int getYear) {
    String      formatted_date="";
         int year = getYear;
         int month = calendar.get(Calendar.MONTH+1);
         int day = calendar.get(Calendar.DATE);
         int hour = calendar.get(Calendar.HOUR);
         int min = calendar.get(Calendar.MINUTE);
         int sec = calendar.get(Calendar.SECOND);
         int am_pm =calendar.get(Calendar.AM_PM);
         formatted_date = month+"/"+day+"/"+year+" "+hour+":"+min+":"+sec+" PM";
         System.out.println("formatted_date is "+formatted_date);     
         o/p : formatted_date is 1/4/2006 1:44:21 PM
         SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    //     DateFormat dateFormat =DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
         Date passdate = new Date();
         try {
              passdate = dateFormat.parse(formatted_date);
         } catch (ParseException e) {
              System.out.println("Invalid Date Parser Exception "+e.getLocalizedMessage()+"DateFormat is "+dateFormat);
              System.out.println("The Date inside the function is "+passdate+"and the year passed is "+year);
    o/p : The Date inside the function is Sat Apr 01 00:00:00 IST 2006and the year passed is 2006
         return passdate;
    Expected O/P is 3/1/2006 1:44:12 PM
         }

  • How to get system date and time?

    Can someone show me a code on how to get system date and time.
    Thanks!

    there is one really easy way to get system time, the api gives a great example of code on this. use gregorian calendar, which you'll find in the api under GregorianCalendar. You only need to create one instance of GC, ie Calendar time = new GregorianCalendar();
    you save seconds, minute and hours into int values, so you don't have to access the system time every second, you can create a thread which adds one to the int second value, if oyu see what i mean, for example, i have saved the hours, minutes and seconds as int values;
    int hour, minute, second;
    i can then create a thread (Thread thread = new Thread(this) and run it like:
    Calendar time;
    int hour, minute, second;
    Thread thread = null;
    public MyTime() {
    hour= time.get(Calendar.HOUR_OF_DAY);
    minute = time.get(Calendar.MINUTE);
    second = time.get(Calendar.SECOND);
    if(thread == null) {
    thread = new Thread(this);
    thread.start();
    public void run() {
    Thread t = Thread.currentThread();
    while(thread == t) {
    thread.sleep(1000);
    second++;
    if(second > 59)
    minute++;
    if(minute>59)
    hour++;
    formatTime();
    public void formatTime() {
    second = (second > 59? 0 : second);
    minute = (minute > 59? 0 : minute);
    hour = (hour > 23? 0 : hour);
    System.out.println(hour+":"+minute+":"+second);
    public static void main(String[] args) {
    new MyTime();
    I know this looks like gibberish but it should work. If not, try to fix the problem, i have written from memory really but i guarantee you, this gets the time then every second, simply adds one to the second and then formats time. You can also access the day, month and year then format them using the above code. I don't like giving code since you should really do these things yourself but it is 2:04am, i have nothing better to do and i am not tired so i did you a favour - i have become what i always did not want to, someone ho stays upall night writing code.

  • How do I put data from every XMLnode related,in separate movieclips when clicking a line in combobox

    How do I put data from every XMLnode related,in separate movieclips when clicking a line in combobox?
    A sample from the XML is like this:
    <Planter>
              <Lauvtre>
                        <Botanisk_navn>Acer campestre</Botanisk_navn>
                        <Norsk_navn>Naverlønn</Norsk_navn>
                        <Farge>Grønn</Farge>
                        <Herdighet>H4</Herdighet>
                        <Høyde>10-15 m</Høyde>
              </Lauvtre>
    I have a combobox where it shows the Botanical name, and the Norwegian name. But the rest of the info has to be shown in separate movieclips.
    Anyone have an idea how to do this? Can I use the trace function maybe? Here is my AS3 code so far:
    var loader:URLLoader = new URLLoader();
    loader.addEventListener(Event.COMPLETE, onLoaded);
    list.addEventListener(Event.CHANGE, itemChange);
    function itemChange(e:Event):void
              ta.text = list.selectedItem.data;
              tb.text = list.selectedItem.label;
    var xml:XML;
    function onLoaded(e:Event):void
              xml = new XML(e.target.data);
              var il:XMLList = xml.Planter.Lauvtre;
              for(var i:uint=0; i<il.length(); i++)
                        list.addItem({data:il.Farge.text()[i] +"\n"+ il.Herdighet.text()[i]+"\n"+ il.Høyde.text()[i],
                                                                label:il.Botanisk_navn.text()[i] +"\n"+ il.Norsk_navn.text()[i]});
    loader.load(new URLRequest("lauvtre.xml"));
    Thanks!
    Rheus.

    Hi! And thank you for helping. Planter is my root node. I tried removing "Planter" from xml.Planter.Lauvtre. It didn't fetch any data then. My code works as is, but what I want the code to do, is to put these 3:
        <Farge>Grønn</Farge>
        <Herdighet>H4</Herdighet>
        <Høyde>10-15 m</Høyde>
    ...into separate textfields.
    It has to be dynamic, so that when I click on one of the plant names in the combobox, the textfields get updated according to what is selected in the combobox.
    I'm pretty new to Actionscript so I have a hard time explaining my problem:
    I want to use the combobox as the menu, that has all the latin plant names listed. When I click on one of the 100 plantnames I want the correlating info from the XML, put in textfields.

  • How to get this date range

    Respecetd guru's,
    i have task to represent this date range start date to end date in every month.
    it show like this..
    01-sep-2009 to 30-sep-2009
    so on...
    plez help me.

    may be you are looking for this
    SQL> SELECT        TO_CHAR (TRUNC (ADD_MONTHS (SYSDATE, LEVEL), 'mm'),
      2                         'dd-mon-yyyy'
      3                        )
      4             || ' to '
      5             || TO_CHAR (LAST_DAY (ADD_MONTHS (SYSDATE, LEVEL)), 'dd-mon-yyyy')
      6                                                                             dt
      7        FROM DUAL
      8  CONNECT BY LEVEL <= 4;   -- change the range here instead of 4 to get a long range
    DT
    01-oct-2009 to 31-oct-2009
    01-nov-2009 to 30-nov-2009
    01-dec-2009 to 31-dec-2009
    01-jan-2010 to 31-jan-2010to get starting from 01-sep-2009
    use like this
    SQL> SELECT        TO_CHAR (TRUNC (ADD_MONTHS (SYSDATE, LEVEL-1), 'mm'),
      2                         'dd-mon-yyyy'
      3                        )
      4             || ' to '
      5             || TO_CHAR (LAST_DAY (ADD_MONTHS (SYSDATE, LEVEL-1)), 'dd-mon-yyyy')
      6                                                                             dt
      7        FROM DUAL
      8  CONNECT BY LEVEL <= 4;
    DT
    01-sep-2009 to 30-sep-2009
    01-oct-2009 to 31-oct-2009
    01-nov-2009 to 30-nov-2009
    01-dec-2009 to 31-dec-2009Edited by: Qwerty on Sep 8, 2009 8:51 PM

Maybe you are looking for

  • TS1424 i've been charged twice for an in-app purchase, how do i get this resolved?

    my son downloaded a game from the app store and as the password wasn't required for 15 minutes he was able to purchase gold coins without my knowledge. However i have now been charged again but nothing else has been purchased. i tried to call apple f

  • SD Overwrite condition type value of subitem with value of mainitem

    Hi, Suppose we have a sales order with a material and a submaterial. On the head material a condition record for according a reduction is found. On the submaterial also but it's different. Our requirement is that if there is a submaterial, the reduct

  • HOW CAN I USE WINDOWS ACCES

    I need a programm for my MacbookPro to use the Windows Programm ACCES who have the solution? regarding, Wim van Bekkum

  • HT201472 How to findout lost Iphone.

    Hello There...  Some one has stolen my Iphone 5 .. Now the number is switched off.. is there any way we could track the mobile with IMEI number... Please note : I don't have Find my Iphone activated. Thanks, Madhu

  • Pagenumbering in Indesign

    Pagenumbering in Indesign: I know how to set the numbering in a document but I dont know how to do it if I want the document to start with f.ex. page 35 instead of page 1. Is there an easy way to do it? Goran W