﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2005 / SQL Server 2005 Integration Services  / Possible to determine the datetime range of loaded data to staging table? / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 07:46:34 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>[quote][b]Phil Parkin (12/28/2012)[/b][hr][quote]i wonder if you all took care of scenario whereby package i executed before or at 8am.[/quote]My solution handles that.[/quote]From what i see, phil your solution will definitely work. However i prefer doing it in conditional split for this. Do not how to convert ur tsql into conditional split expression</description><pubDate>Wed, 02 Jan 2013 00:49:11 GMT</pubDate><dc:creator>10e5x</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>[quote][b]SatishAyyar (12/28/2012)[/b][hr]My solution handles too[/quote]Hi satish,I tried out your solution, it does not met my requirement. I guess your solution take 73 hrs before my current sys date time. This is not what i want. The start time should be 73 hours ago from the end time while the end time is the nearest 8am(past). Thanks anyway. Btw if u are not sure what i am talking about, kindly study the scenarios. Thanks for the input</description><pubDate>Wed, 02 Jan 2013 00:47:34 GMT</pubDate><dc:creator>10e5x</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>My solution handles too</description><pubDate>Fri, 28 Dec 2012 08:21:30 GMT</pubDate><dc:creator>SatishAyyar</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>[quote][b]Phil Parkin (12/28/2012)[/b][hr][quote]i wonder if you all took care of scenario whereby package i executed before or at 8am.[/quote]My solution handles that.[/quote]Thanks! :-D</description><pubDate>Fri, 28 Dec 2012 02:24:17 GMT</pubDate><dc:creator>10e5x</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>[quote]i wonder if you all took care of scenario whereby package i executed before or at 8am.[/quote]My solution handles that.</description><pubDate>Fri, 28 Dec 2012 02:04:01 GMT</pubDate><dc:creator>Phil Parkin</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>Thanks to both of you, currently out of office cant test our both solutions. Will test as soon as i get back. Btw from what i read from both your solutions, i wonder if you all took care of scenario whereby package i executed before  or at 8am. Which means this examples:Datetime when package run: 26/12/12 0759Startdate: 22/12/12 0700Enddate: 25/12/12 0800Datetime when package run: 26/12/12 0800Startdate: 22/12/12 0700Enddate: 25/12/12 0800Just clarifying. Thanks alot</description><pubDate>Fri, 28 Dec 2012 01:40:22 GMT</pubDate><dc:creator>10e5x</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>Here's my pseudo-code expanded a bit to accommodate the start and end date bits:[code="sql"]declare @StartDate datetime	,@EndDate datetimeset @EndDate = dateadd(hour, 8, DATEADD(dd, 0, DATEDIFF(dd, 0, DATEADD(HOUR, - 8, getdate()))))set @StartDate = dateadd(hour, - 73, @EndDate)select col1	,col2from tablewhere [convert varchar date and time to datetime] between @StartDate		and @EndDate[/code]That's how it works in T-SQL. Just need to convert that to Oracle.--Edit: fixed typo.</description><pubDate>Fri, 28 Dec 2012 00:33:45 GMT</pubDate><dc:creator>Phil Parkin</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>You may write the expression something like this in the conditional split(DT_DBTIMESTAMP)(event_d + " " + event_t) &amp;gt;= DATEADD("HH",-73,GETDATE()) &amp;&amp; (DT_DBTIMESTAMP)(event_d + " " + event_t) &amp;lt;= DATEADD("HH",8,(DT_DBDATE)(GETDATE()))</description><pubDate>Thu, 27 Dec 2012 22:33:16 GMT</pubDate><dc:creator>SatishAyyar</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>[quote][b]Phil Parkin (12/27/2012)[/b][hr][quote][b]10e5x (12/27/2012)[/b][hr]You are right, definately will have overhead. i try to get it done first before looking at efficiency issue. Actually my problem is defining startDate and endDate. Thanks phil[/quote]OK, I've looked at your original post again. I'm not sure I understand the logic for setting the start and end dates - can you explain it?[/quote]The start date will always be 73 hours before the end date. While the end date will be the nearest 8am but its definitely a datetime of a past. E.g:Datetime when package run: 24/12/12 0900Startdate: 21/12/12 0700Enddate: 24/12/12 0800Datetime when package run: 25/12/12 2300Startdate: 22/12/12 0700Enddate: 25/12/12 0800Datetime when package run: 26/12/12 0759Startdate: 22/12/12 0700Enddate: 25/12/12 0800Datetime when package run: 26/12/12 0800Startdate: 22/12/12 0700Enddate: 25/12/12 0800Datetime when package run: 26/12/12 0805Startdate: 23/12/12 0700Enddate: 26/12/12 0800As u can see i want the data to be included from my soure to my staging span accross 73hrs. I want 73hrs worth of event data. So EVENT_D + EVENT_T should be between the Startdate and EnddateThanks in Advance,10e5x</description><pubDate>Thu, 27 Dec 2012 20:14:59 GMT</pubDate><dc:creator>10e5x</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>[quote][b]10e5x (12/27/2012)[/b][hr]You are right, definately will have overhead. i try to get it done first before looking at efficiency issue. Actually my problem is defining startDate and endDate. Thanks phil[/quote]OK, I've looked at your original post again. I'm not sure I understand the logic for setting the start and end dates - can you explain it?</description><pubDate>Thu, 27 Dec 2012 04:12:36 GMT</pubDate><dc:creator>Phil Parkin</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>You are right, definately will have overhead. i try to get it done first before looking at efficiency issue. Actually my problem is defining startDate and endDate. Thanks phil</description><pubDate>Thu, 27 Dec 2012 03:06:13 GMT</pubDate><dc:creator>10e5x</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>OK, then you need help from an Oracle developer to design your SELECT statement for the OLEDB source.Select col1, col2from tablewhere [convert varchar date and time to datetime] between [startdate] and [enddate]The problem with trying to do this all in SSIS is that you will always have to process all of the rows in the source table. If the source table is growing, as I mentioned before, your process will get slower and slower.</description><pubDate>Thu, 27 Dec 2012 02:54:43 GMT</pubDate><dc:creator>Phil Parkin</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>Its Oracle View</description><pubDate>Thu, 27 Dec 2012 02:48:41 GMT</pubDate><dc:creator>10e5x</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>Is the source a SQL Server database?</description><pubDate>Thu, 27 Dec 2012 02:18:04 GMT</pubDate><dc:creator>Phil Parkin</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>Hi Phil,Once again thanks for replying and helping. Ya my source it is from RDBMS. Your suggestions are too complicated to me. I am trying some other simpler way. Maybe two new derive column of EVENT_D and EVENT_T as datetime first then use conditional split. Btw are u able to help me with the expression?</description><pubDate>Thu, 27 Dec 2012 02:09:33 GMT</pubDate><dc:creator>10e5x</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>Depending on the nature of your OLEDB source (is it an RDBMS?), the most efficient way would be to CAST the varchar date/time columns to a single column with a datetime datatype and use a select query with an appropriate WHERE clause to provide the data (and not just the whole table).An even better way would be to add a proper datetime column to the source data, but I'm assuming that's not allowed? If there's a lot of data in this table and it's growing, any method is going to gradually grind to a halt, unless you are somehow able to get a useful index on it (eg, in SQL Server, on a computed datetime column added to the base table).</description><pubDate>Thu, 27 Dec 2012 01:53:13 GMT</pubDate><dc:creator>Phil Parkin</dc:creator></item><item><title>RE: Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>You may use a conditional split transformation in the Data flow tab. You can write any number of conditions in this transformation and each condition have a respective output. So which ever condition is satisfied that specific data can be directed to the next step as you want.You can also use functions to change the datatype of your columns as per your need</description><pubDate>Wed, 26 Dec 2012 21:37:30 GMT</pubDate><dc:creator>SatishAyyar</dc:creator></item><item><title>Possible to determine the datetime range of loaded data to staging table?</title><link>http://www.sqlservercentral.com/Forums/Topic1400438-148-1.aspx</link><description>Hi all,I have created a SSIS package. In the control flow i have a Execute SQL task which will truncate my staging table and followed by a Data Flow task that loads the source data to my destination staging table. Currently, my Data Flow consist of only a OLE DB Source and a OLE DB destination. However i would like to define the life range of data in my staging table but i do not know how to achieve that. Meaning i will only extract a specified range of data from source and load it into the staging table. In my source, there are two varchar fields EVENT_D and EVENT_T. So for example, if i run my package at 26/12/12 11:00:00, Data to be extracted and load into staging are data with EVENT_D + EVENT_T between 23/12/12 07:00:00 to 26/12/12 08:00:00and if i run my package at 27/12/12 14:00:00 my loaded data will be between: 27 Dec 0800 - 73 hours TO 27 Dec 0800.and if i run my package at 27/12/12 07:59:00(which is v rare) my loaded data will be between:23/12/12 07:00:00 to 26/12/12 08:00:00Is this achievable? I guess one of the problem would be my two varchar field and it is in the format of DD/MM/YYYY hh:mm:ss Thanks,10e5x</description><pubDate>Wed, 26 Dec 2012 20:37:53 GMT</pubDate><dc:creator>10e5x</dc:creator></item></channel></rss>