Help: how to compute duration between 2 dates, when these dates on 2 rows?

Hello,
We are on 11g.
We have a table with times saved in one column. Then each row as a différent date value.
There is no pb to order the query on this date column (obviously)
Now, we need to compute the period of time between 2 successive rows.
I have firstly thought about using a cursor, loop on the cursor,compute and update the "period" column.
this is the basic option
Now I would like to know if, using a single query, I could directly get the computation I want ?
here is my example:
WITH t AS (
SELECT 'aaa' col1, to_date( '20100201 09:23:50', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
UNION
SELECT 'aaa' col1, to_date( '20100201 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
UNION
SELECT 'aaa' col1, to_date( '20100207 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
UNION
SELECT 'bbb' col1, to_date( '20100202 09:21:10', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
UNION
SELECT 'bbb' col1, to_date( '20100203 08:11:06', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
UNION
SELECT 'bbb' col1, to_date( '20100203 15:13:55', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
UNION
SELECT 'bbb' col1, to_date( '20100210 10:14:27', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
SELECT col1, to_char( date1,'YYYYMMDD HH24:MI:SS') date1  FROM t
ORDER BY col1, date1;ideally, this is what I'd like to get (if my computation is correct)
COL DATE1               DURATION
aaa 20100201 09:23:50          0
aaa 20100201 13:14:33      13843
aaa 20100207 13:14:33     518400
bbb 20100202 09:21:10          0
bbb 20100203 10:11:06      89396
bbb 20100203 15:13:55      18169
bbb 20100210 17:14:27     612032I hope I'm clear !!!
Thanks a lot, in advance, for your help
Olivier

Sure; it's easy with the use of the lag analytic function:
WITH t AS (SELECT 'aaa' col1, to_date( '20100201 09:23:50', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
           UNION ALL
           SELECT 'aaa' col1, to_date( '20100201 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
           UNION ALL
           SELECT 'aaa' col1, to_date( '20100207 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
           UNION ALL
           SELECT 'bbb' col1, to_date( '20100202 09:21:10', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
           UNION ALL
           SELECT 'bbb' col1, to_date( '20100203 08:11:06', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
           UNION ALL
           SELECT 'bbb' col1, to_date( '20100203 15:13:55', 'YYYYMMDD HH24:MI:SS') date1 FROM dual
           UNION ALL
           SELECT 'bbb' col1, to_date( '20100210 10:14:27', 'YYYYMMDD HH24:MI:SS') date1 FROM dual),
t_diff as (SELECT col1,
                  to_char( date1,'YYYYMMDD HH24:MI:SS') date1,
                  (date1 - lag(date1, 1, date1) over (partition by col1 order by date1))*24*60*60 date_diff
           FROM   t)
select col1,
       date1,
       sum(date_diff) over (partition by col1 order by date1) duration
from   t_diff
ORDER BY col1, date1;Edited by: Boneist on 15-Feb-2010 16:39
(I can't read; was originally giving the cumulative total of the duration. D'oh!)
ETA2: Take note of the additional parameters I've used in the lag() - the third parameterd handles what the value of the field should be if there is no previous row, so there's no need to use nvl elsewhere in the query to handle that situation.
Edited by: Boneist on 15-Feb-2010 16:42

Similar Messages

  • How to caluclate tat between two dates of one timestamp field

    Hi,
    could some one help how to caluclate days between two dates of single timestamp filed and with this
    query
    Select * from m_activity_transaction where actn_opp_id in (
    Select actn_opp_id from m_activity_transaction where ACTN_ACTV_ID = 218
    Group by actn_opp_id
    having count(*) > 1 ) and ACTN_ACTV_ID = 218
    order by actn_performed_on
    iam getting output is
    ACTN_ID ACTN_OPP_ID ACTN_PERFORMED_ON
    319415 95831 27-JAN-12 11.06.20.000000 AM
    315249 95831 08-FEB-12 05.32.54.000000 PM
    301927 103509 20-DEC-11 04.01.43.000000 PM
    301458 103509 19-DEC-11 04.51.03.000000 PM
    294841 115840 10-JAN-12 03.20.12.000000 PM
    312062 115840 11-JAN-12 05.17.06.000000 PM
    and i nedd to caluclate no.of days between two dates like 27-JAN-12 11.06.20.000000 AM and 08-FEB-12 05.32.54.000000 PM where actn_id is unique AND ACTN_OPP_ID IS NOT UNIQUE.
    Thanks in Advance,
    vvr.

    This way?
    with data as
    select 315249 a, 95831 b, to_timestamp('27-JAN-12 11.06.20.000000 AM', 'DD-MON-RR HH.MI.SS.FF6 AM') dt from dual union all
    select 319415, 95831, to_timestamp('08-FEB-12 05.32.54.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 301927, 103509 , to_timestamp('20-DEC-11 04.51.03.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 301458 , 103509 , to_timestamp('19-DEC-11 04.01.43.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 363810 , 144656 , to_timestamp('27-JUN-12 12.43.28.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 363500 , 144656 , to_timestamp('26-JUN-12 11.41.50.000000 AM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual union all
    select 363354 , 144656 , to_timestamp('25-JUN-12 12.41.13.000000 PM', 'DD-MON-RR HH.MI.SS.FF6 AM') from dual
    select a, b, diff
      from (
            select a, b, extract( day from (dt - lag(dt) over (partition by b order by dt, a)) ) diff
              from data
           ) tab
    where tab.diff is not null;
    A                      B                      DIFF                  
    319415                 95831                  12                    
    301927                 103509                 1                     
    363500                 144656                 0                     
    363810                 144656                 1

  • How to calculate days between two DATES

    How to calculate days between two DATES ?
    which is the functional module for that ?
    help me

    Hi,
    use function module : it works,
    HR_HK_DIFF_BT_2_DATES
    give output format = 03 and get the value in days.
    code is as below :
    data : DATE1 type P0001-BEGDA,
    DATE2 type P0001-BEGDA,
    YEARS type P0347-SCRYY,
    MONTHS type P0347-SCRMM,
    DAYS type P0347-SCRDD.
    date1 = '20070331'.
    date2 = '20070101'.
    CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
    EXPORTING
    DATE1 = date1
    DATE2 = date2
    OUTPUT_FORMAT = '03'
    IMPORTING
    YEARS = years
    MONTHS = months
    DAYS = days
    EXCEPTIONS
    INVALID_DATES_SPECIFIED = 1
    OTHERS = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    write : days.
    Reward points, if helpful,
    Regards,
    Sandeep Kaushik

  • How can get difference between 2 dates in the form of days

    how can get difference between 2 dates in the form of days

    Hi,
    Check the following program:
    REPORT ZDATEDIFF.
    DATA: EDAYS   LIKE VTBBEWE-ATAGE,
          EMONTHS LIKE VTBBEWE-ATAGE,
          EYEARS  LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
                TODATE   LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
    call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
      exporting
        i_date_from          = FROMDATE
        i_date_to            = TODATE
      I_FLG_SEPARATE       = ' '
      IMPORTING
        E_DAYS               = EDAYS
        E_MONTHS             = EMONTHS
        E_YEARS              = EYEARS.
    WRITE:/ 'Difference in Days   ', EDAYS.
    WRITE:/ 'Difference in Months ', EMONTHS.
    WRITE:/ 'Difference in Years  ', EYEARS.
    INITIALIZATION.
    FROMDATE = SY-DATUM - 60.
    Regards,
    Bhaskar

  • How to get days between two dates

    Hi ,
    How to get days between two dates.
    Regards,
    Ramesh.

    Hi Ramesh,
    REPORT ZDATEDIFF.
    DATA: EDAYS   LIKE VTBBEWE-ATAGE,
          EMONTHS LIKE VTBBEWE-ATAGE,
          EYEARS  LIKE VTBBEWE-ATAGE.
    PARAMETERS: FROMDATE LIKE VTBBEWE-DBERVON,
                TODATE   LIKE VTBBEWE-DBERBIS DEFAULT SY-DATUM.
    call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
      exporting
        i_date_from          = FROMDATE
        i_date_to            = TODATE
      I_FLG_SEPARATE       = ' '
      IMPORTING
        E_DAYS               = EDAYS
        E_MONTHS             = EMONTHS
        E_YEARS              = EYEARS.
    WRITE:/ 'Difference in Days   ', EDAYS.
    WRITE:/ 'Difference in Months ', EMONTHS.
    WRITE:/ 'Difference in Years  ', EYEARS.
    INITIALIZATION.
    FROMDATE = SY-DATUM - 60.

  • Calculate duration between start date and end date

    Hi everyone,
    I'm facing with problem when calculating duration between start & end with this function below . This fuction  is working well, but i want to change working time from 8:00 am to 17:30 pm instead of 17:00 , and lunch time from 12:00 to 13:30 instead
    of 13:00 as present . Problem is , i changed data type of start hour and end hour from INT to decimal . But it is still wrong .
    Pls help me . It's very urgent bcoz i need it for monthly report .
    Many thanks .
    Here is function which im using :
    ALTER Function [dbo].[GetWorkingMin](@pStartDate DateTime, @pEndDate DateTime) Returns Int
    AS
    Begin
          Declare @StartDate DateTime = @pStartDate
          Declare @EndDate DateTime = @pEndDate
        Declare @WorkMin int = 0   -- Initialize counter
        Declare @Reverse bit       -- Flag to hold if direction is reverse
        Declare @StartWorkingHour int = 8   -- Start of business hours (can be supplied as an argument if needed)
        Declare @EndWorkingHour int = 17    -- End of business hours (can be supplied as an argument if needed)
        Declare @Holidays Table (HDate DateTime)   --  Table variable to hold holidayes
          Declare @LunchHour int = 12
          Declare @StartHour int = DatePart(HH, @StartDate)
          Declare @EndHour int = DatePart(HH, @EndDate)
        -- If dates are in reverse order, switch them and set flag
        If @StartDate>@EndDate
        Begin
            Declare @TempDate DateTime=@StartDate
            Set @StartDate=@EndDate
            Set @EndDate=@TempDate
            Set @Reverse=1
        End
        Else Set @Reverse = 0
        -- Get country holidays from table based on the country code
        Insert Into @Holidays (HDate) Select HDate from HOLIDAY Where HDATE>=DateAdd(dd, DateDiff(dd,0,@StartDate), 0)
        If DatePart(HH, @StartDate)<@StartWorkingHour
        begin
                Set @StartDate = DateAdd(hour, @StartWorkingHour, DateDiff(DAY, 0, @StartDate))  
                -- If Start time is less than start hour, set it to start hour
                Set @StartHour = DatePart(HH, @StartDate)
        end
        If DatePart(HH, @StartDate)>=@EndWorkingHour
        begin
                Set @StartDate = DateAdd(hour, @StartWorkingHour+24, DateDiff(DAY, 0, @StartDate))
                -- If Start time is after end hour, set it to start hour of next day
                Set @StartHour = DatePart(HH, @StartDate)
                --return DatePart(day, @StartDate)
        end
        If DatePart(HH, @EndDate)>=@EndWorkingHour
        begin
                Set @EndDate = DateAdd(hour, @EndWorkingHour, DateDiff(DAY, 0, @EndDate))
                -- If End time is after end hour, set it to end hour
                Set @EndHour = DatePart(HH, @EndDate)           
        end
        If DatePart(HH, @EndDate)<@StartWorkingHour
        begin
                Set @EndDate = DateAdd(hour, @EndWorkingHour-24, DateDiff(DAY, 0, @EndDate))
                -- If End time is before start hour, set it to end hour of previous day
                Set @EndHour = DatePart(HH, @EndDate)
        end
        If (@StartHour>=@LunchHour and @StartHour < (@LunchHour +1))
        Begin
                Set @StartDate = DateAdd(hour, @LunchHour + 1, DateDiff(DAY, 0, @StartDate))
                -- If Start time is in lunch time, set it to 12
                Set @StartHour = @LunchHour + 1   
        End
        If (@StartHour>=@LunchHour and DatePart(DW, @StartDate) = 7)
        Begin
                Set @StartDate = DateAdd(hour, @StartWorkingHour + 24, DateDiff(DAY, 0, @StartDate))
                Set @StartHour = DatePart(HH, @StartDate)
        End
        If (@EndHour>=@LunchHour and @EndHour < (@LunchHour +1))
        Begin
                Set @EndDate = DateAdd(hour, @LunchHour +1, DateDiff(DAY, 0, @EndDate))
                -- If End time is in lunch time, set it to 13
                Set @EndHour = @LunchHour + 1
          End
          If (DatePart(DW, @EndDate) = 7 and DatePart(HH, @EndDate) >= @LunchHour) Set @EndDate = DateAdd(hour, @LunchHour, DateDiff(DAY, 0, @EndDate)) -- If End day is Saturday and End time is after end hour, set it to end hour of saturday
        If @StartDate>@EndDate Return 0
        -- If Start and End is on same day
        If DateDiff(Day,@StartDate,@EndDate) <= 0
        Begin
            If (Datepart(dw,@StartDate)>1 And DATEPART(dw,@StartDate)<7)  
            -- If day is between sunday and saturday
                If (Select Count(*) From @Holidays Where HDATE=DateAdd(dd, DateDiff(dd,0,@StartDate), 0)) = 0  
                -- If day is not a holiday
                    If @EndDate<@StartDate Return 0 Else
                    Begin
                                  Set @WorkMin=DATEDIFF(MI, @StartDate, @EndDate)
                                  -- Calculate difference
                                  If (@StartHour <= @LunchHour and @EndHour >= @LunchHour + 1)
                                        Set @WorkMin = @WorkMin - 60;                                   
                            End
                Else Return 0
            Else Begin
                      if (DATEPART(dw,@StartDate)=7) set @WorkMin = @WorkMin + DATEDIFF(MI, @StartDate, @EndDate);
                      Return @WorkMin
            End
        End
        Else Begin
            Declare @Partial int=1   
            -- Set partial day flag
            While DateDiff(Day,@StartDate,@EndDate) > 0   
            -- While start and end days are different
            Begin
                If Datepart(dw,@StartDate)>1 And DATEPART(dw,@StartDate)<7    --  If this is a weekday
                Begin
                    If (Select Count(*) From @Holidays Where HDATE=DateAdd(dd, DateDiff(dd,0,@StartDate), 0)) = 0  -- If this is not a holiday
                    Begin
                        If @Partial=1  
                        -- If this is the first iteration, calculate partial time
                        Begin
                            Set @WorkMin=@WorkMin + DATEDIFF(MI, @StartDate, DateAdd(hour, @EndWorkingHour, DateDiff(DAY, 0, @StartDate)))
                            If (@StartHour <= @LunchHour) Set @WorkMin = @WorkMin - 60;
                            Set @StartDate=DateAdd(hour, @StartWorkingHour+24, DateDiff(DAY, 0, @StartDate))
                            Set @Partial=0
                        End
                        Else Begin     
                        -- If this is a full day, add full minutes
                            Set @WorkMin=@WorkMin + (@EndWorkingHour-@StartWorkingHour - 1)*60        
                            Set @StartDate = DATEADD(DD,1,@StartDate)
                        End
                    End
                    Else Set @StartDate = DATEADD(DD,1,@StartDate)  
                End
                Else Begin
                            If (DATEPART(dw,@StartDate)=7)
                            Begin                   
                                  Set @WorkMin = @WorkMin + DATEDIFF(MI, @StartDate, DateAdd(hour, @LunchHour, DateDiff(DAY,
    0, @StartDate)));
                            End
                            --Set @StartDate = DATEADD(DD,1,@StartDate)
                            Set @StartDate = DateAdd(hour, @StartWorkingHour + 24, DateDiff(DAY, 0, @StartDate))
                                  Set @StartHour = DatePart(HH, @StartDate)
                      End
            End
            If Datepart(dw,@StartDate)>1 And DATEPART(dw,@StartDate)<7  
            -- If last day is a weekday
                If (Select Count(*) From @Holidays Where HDATE=DateAdd(dd, DateDiff(dd,0,@StartDate), 0)) = 0   
                -- And it is not a holiday
                    Begin
                                  If @Partial=0 Set @WorkMin=@WorkMin + DATEDIFF(MI, @StartDate, @EndDate) Else
    Set @WorkMin=@WorkMin + DATEDIFF(MI, DateAdd(hour, @StartWorkingHour, DateDiff(DAY, 0, @StartDate)), @EndDate)
                                  If (@EndHour >= (@LunchHour + 1)) Set @WorkMin = @WorkMin - 60;
                            End   
                If (DATEPART(dw,@EndDate)=7)
                Begin
                      Set @WorkMin = @WorkMin + DATEDIFF(MI, DateAdd(hour, @StartWorkingHour, DateDiff(DAY, 0, @EndDate)),@EndDate);        
                End
        End
        If @Reverse=1 Set @WorkMin=-@WorkMin
        Return @WorkMin
    End

    The problem is you cannot specify partial hours.
    I think your best bet would be to alter the function sufficiently so it will accept times instead of hours, and where you're making comparisons to the hour, use dates/date functions instead.
    Then, just set the variable as a full time (or datetime, if you need).

  • Duration between Start date of the project and user defined  Date

    Hi All,
    I need to calculate the the duration between the projects start  date and the date (month and year) the User defines. Also wat charateristics do we use to to restrict 0DATE_KYF to differentiate between forcast date and actual date.Any help will be appreciated

    You need to create formula variable for the date objects and used those variables to calculate the difference of the dates in either formula or calculated key figure.
    thanks.
    Wond

  • Duration between two date

    If there is two date and I want to know how many days, mouths and years between this two date (the duration between them).
    example
    the first date 15/01/2000
    the second date 12/02/1980
    the answer must be 19 years ,11 mouths and 3 days.
    how can I write code of this describtion?
    note:
    don't forgot every four years have a year
    with 366 days not 365 days.

    I know that the differant between date is number of days but I can say the age of person to the date 15/1/2000 is for example 19 years, 11 mouths and 3 days if this person born in 12/2/1980.and I ask about this problem.

  • How to retrieve day between two dates?

    Hi all,
    Hope doing well,
    sir i am retrieving day between two dates in sql server like this.
    select datediff(day,'2012-10-03 00:00:00.000','2012-10-05 00:00:00.000')
    and getting result that is: 2
    but how this type of query i'll use in oracle?
    thanks,

    Just do minus
    diff := date_variable2-date_variable1;The difference sill be in days.
    If you want just the differences in days (Neglecting time part)
    diff := trunc(date2)-trunc(date1);

  • How to Calculate second between two dates?

    I'm wish to create a ref ID using seconds between two dates as the uniue number. I usually use DateDiff function in VB to calculate the ref ID. But now instead developing using VB, i'm using java in developing my project. I wonder is there any class similar to the datediff function? Please advice.Thank you

    diff_sec =( Date1.getSeconds() - Date2.getSeconds());

  • How to calculate days between 2 dates excluding public holidays over SAP ?

    Hi
    Have a universe over SAP data. Trying to calculate days between 2 dates. SAP holds Public Holiday data in various tables e.g  Thol and data is updated via scal. Using my univeres as a source I want to run  reports for different countries so need to have various bank holidays not just UK. In SAP function modules handle this. Has anyone designed a solution to cater for this situation in a universe ?
    Thanks in advance
    M

    Hi,
    I assume you mean SAP R/3 (ECC) when you write SAP and SAP BW.
    Are you using BW? If so, I would load the data into SAP BW, create a query using customer exit variables and build your universe on top of that...
    -J

  • How to make search between two dates accept null not obligatory search proplem

    Hi guys when i search record between two dates it works ok success but you must enter date from and dateto first to  to make search
    i will show what i need from this example
    I need to search dynamic by 4 textbox
    1-datefrom
    2-dateto
    3-EmployeeNo
    4-EmployeeName
    but search i need must be dynamic meaning
    if i enter employee no only give me employee no found in database
    if i enter employee name give me employees found with this name using like
    if i enter all 4 text box null and enter button search get all data
    but i have proplem in this query when i need to search by click search button
    i must write date from and date to firstly then write employee no or employee name if i need to search
    so that i need to search by employee no alone or employee name alone without using date from and date to
    And if i search without using datefrom and dateto it give me message error 'string wasnot recognized as valid datetime"
    my stored procedure and code as following :
    ALTER proc [dbo].[CollectsearchData]
    @StartDate datetime,
    @EndDate datetime,
    @EmployeeID  NVARCHAR(50),
    @EmployeeName  nvarchar(50)
    as
    Begin
    Declare @SQLQuery as nvarchar(2000)
    SET @SQLQuery ='SELECT * from ViewEmployeeTest Where (1=1)'
    If (@StartDate is not NULL)
    Set @SQLQuery = @SQLQuery + ' And (joindate >= '''+ Cast(@StartDate as varchar(100))+''')'
    If (@EndDate is not NULL)
    Set @SQLQuery = @SQLQuery + ' And (joindate <= '''+ Cast(@EndDate as varchar(100))+''')' 
    If @EmployeeID <>''
    Set @SQLQuery = @SQLQuery + 'And (EmployeeID = '+ @EmployeeID+') '
    If @EmployeeName Is Not Null
    Set @SQLQuery = @SQLQuery + ' AND (DriverName LIKE
    ''%'+@EmployeeName+'%'') '
    Print @sqlQuery
    Exec (@SQLQuery) 
    End
    Function using
    public DataTable SearchDataA(string ConnectionString,string EmployeeNo,string EmployeeName, DateTime StartDate, DateTime EndDate)
    SqlConnection con = new SqlConnection(ConnectionString);
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = con;
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "CollectsearchData";//work
    cmd.Parameters.Add("@StartDate", SqlDbType.DateTime);
    cmd.Parameters.Add("@EndDate", SqlDbType.DateTime);
    cmd.Parameters.Add("@EmployeeID", SqlDbType.NVarChar, 50);
    cmd.Parameters.Add("@EmployeeName", SqlDbType.NVarChar, 50);
    cmd.Parameters["@StartDate"].Value = StartDate;
    cmd.Parameters["@EndDate"].Value = EndDate;
    cmd.Parameters["@EmployeeID"].Value = EmployeeNo;
    cmd.Parameters["@EmployeeName"].Value = EmployeeName;
    SqlDataAdapter da = new SqlDataAdapter();
    da.SelectCommand = cmd;
    DataSet ds = new DataSet();
    da.Fill(ds);
    DataTable dt = ds.Tables[0];
    return dt;
    interface button search
     try
    CultureInfo ukCulture = new CultureInfo("en-GB");             
    FleetManagment.Fleet fleet = new FleetManagment.Fleet();
    DataTable Table = fleet.SearchDataA("Data Source=" + value1 + ";Initial Catalog=" + value2 + ";User ID=" + value3 + ";Password=" + value4 + "",textBox3.Text,textBox4.Text, DateTime.Parse(textBox1.Text,
    ukCulture.DateTimeFormat), Convert.ToDateTime(textBox2.Text, ukCulture.DateTimeFormat));
    dataGridView1.DataSource = Table;
    dataGridView1.Refresh();
    catch (Exception ex)
    MessageBox.Show(ex + "error");

    Yes, the below code should not be passed any value: (I am not sure of the syntax in .NET,Sorry) 
    --If startdate len is 0 - do not assign this value
    cmd.Parameters["@StartDate"].Value = StartDate;
    --If endate len is 0 - do not assign this value
    cmd.Parameters["@EndDate"].Value = EndDate;

  • How to count days between two dates excluding saterady and sunday

    Hi all
    iam working on oracle sql/plsql.
    In my application , i need to caliculate leave days between two dates excluding saterady and sunday
    Please tell me the solution if any one knows
    thanks in advance ,
    balu

    More modern version:
    WITH date_tab AS
    (SELECT TO_DATE ('&from_date', 'dd-MON-yyyy')
    + LEVEL
    - 1 business_date
    FROM DUAL
    CONNECT BY LEVEL <=
    TO_DATE ('&to_date', 'dd-MON-yyyy')
    - TO_DATE ('&from_date', 'dd-MON-yyyy')
    + 1)
    SELECT business_date
    FROM date_tab
    WHERE TO_CHAR (business_date, 'DY') NOT IN ('SAT', 'SUN');Thank you,
    Tony Miller
    Webster, TX
    Never Surrender Dreams!
    JMS
    If this question is answered, please mark the thread as closed and assign points where earned..

  • How to use EVS with different data in each row, in a Java Web Dynpro table?

    Hi all,
    I am using EVS in a column of java web dynpro table.
    Let's say the name, and context attribute, of this column is column1.
    It's filled dynamically using an RFC, that uses as input parameter the value of another column, and related context attribute, from the same table (Let's call it column2).  Obviously, from the same row. So, in other words: the values of the EVS in column1 of row1, are dependent of the value of column2 of row1. And the values of the EVS in column1 of row2, are dependent of the value of column2 of row2. And so on... Hope i could explain myself ok.
    The code I'm using works great for filling the EVS dynamically:
    IWDAttributeInfo attrInfo = wdContext.nodeDetail().getNodeInfo().getAttribute(nodeElement.COLUMN1);
    ISimpleTypeModifiable siType = attrInfo.getModifiableSimpleType();
    IModifiableSimpleValueSet<String> value = siType.getSVServices().getModifiableSimpleValueSet();
    value.clear();
    if(this.initRFC_Input(nodeElement.getColumn2())){
         for (int i = 0; i < wdContext.nodeRFCresult().size(); i++){
              value.put(wdContext.nodeRFCresult().getRFCresultElementAt(i).getLgort()
                 , wdContext.nodeRFCresult().getRFCresultElementAt(i).getLgobe());
    In this code, nodeElement is the context row of the table that is passed dynamically to the method when the value of colum2 is changed.
    HOWEVER, the problem I'm having is that after executing this code, EACH NEW ROW that is added to the table has by default the same values as the first row, in the column1 EVS. And, for example, if I refresh the values of the column1 EVS in row 2, all EVS values in the other rows are also refreshed with the same values as the ones of EVS in row 2.
    How can I make sure each row EVS has its own set of independent values, so they don't mess with each other?
    Hope you guys can help me. And please, let me know if I didn't explain myself correctly!
    Thanks!

    I just did as you said (I think), but it's still having the same behaviour as before (same data for all EVS in the table).
    Here´s what I did:
    I
    In node "Detail" (cardinality 0...n, singleton set to true), which is binded to the table, I created a child node named "Column1Values" wth cardinality 1...1 and singleton set to false.
    "Column1Values" node has an attribute called "column1", of type String.
    I did the binding between attribute "column1" and the column1 inputfield celleditor in the table.
    I created an event called Column2Changed and binded it to the column2 celleditor of the table. I added a parameter called nodeElement of type IPrivateCompView.IDetailElement to this event, and mapped it to the column2 editor in the table so that I can dynamically get the nodeElement that is being affected.
    I added the following code to the onActionColumn2Changed(wdEvent, nodeElement) method that gets created in the view:
    IWDAttributeInfo attrInfo = nodeElement.nodeColumn1Values().getNodeInfo().getAttribute("column1");
    ISimpleTypeModifiable siType = attrInfo.getModifiableSimpleType();
    IModifiableSimpleValueSet<String> value = siType.getSVServices().getModifiableSimpleValueSet();
    if(this.initRFC_Input(nodeElement.getColumn2())){
         for(int i =0; i < wdContext.nodeRFCresults().size(); i++){
              value.put(wdContext.nodeRFCresults().getRFCresultsElementAt(i).getId(),
                                  wdContext.nodeRFCresults().getRFCresultsElementAt(i).getDesc());
    And with this, I still get the original problem... When the EVS of one row is updated, ALL other EVS of the table get also updated with the same values.
    What am I missing? Sorry Govardan, I bet I'm not seeing something really obvious... hopefully you can point me in the right direction.
    Thanks!

  • How do I change between iPhoto Libraries when I am importing pics to another website?

    When I import pics to my website I click on Import photos and the standard apple screen (Firefox Edit  in menu bar) comes up so I click on Pictures, then iPhoto, then Events and choose the individual photos, but  only the one library shows there.  I do know how to change between the libraries when opening the iphoto library by using the options tab, but that does not work in this instance?
    ilife 11, OSX 10.6.8.

    Correct - that is not how you access your photos
    You use the media browser in the lower left hand corner of the upload window under media ==> photos ==> iPhoto
    See this user tip for complete details on accessing your photos correctly
    LN

Maybe you are looking for

  • Changing default color for arrows from the Shapes palette.

    I'm building a tutorial website for how to buy kitchens from my cabinetshop. I use a lot of arrow type lines from the Shapes Palette. After I create the arrow-line I have to re-color it to red with the Graphics Inspector. Is there a way to set red as

  • Zen Vision M: Album fol

    Is there any way that I can eliminate the album folder so when I search for music by artist that it goes from Artist directly to Songs instead of Artist>Album>Song Thanks, Blake

  • Want to import Class Attributes from ERP to PI

    Hi all, I'm publishing Asset Information from SAP to PI to an external system. The information includes EQUNR,SERNR, TIDNR and Partner information. In PI I manually defined a DataType in PI of Asset and then created a service definition. I then gener

  • Data Filtering Problem

    Hi all, i have a report which has to display country wise sales based on the prompt(having drop down values: India, Australia, SouthAfrica). Here i have set filter for the country (Is prompted) in the report. On the selection of the prompt value, the

  • MD5 - Size Of Digested Byte Array

    Hey There. After MD5 digesting and then Base64Encoding a string, I would end up with a byte array such as this: GH70Q2Ei0cwvQNwrkvDroA== It changes with the input, but is always 24 characters in length. I would have thought it to be 32 characters. An