How to get the most current file based on date and time stamp using SSIS?

Hello,
Let us assume that files get copied in a specific directory. We need to pick up a file and load data. Can you guys let me know how to get the most current file based on date and time stamp using SSIS?
Thanks
thx regards dinesh vv

hi simon
i excuted this script it is giving error..
   Microsoft SQL Server Integration Services Script Task
   Write scripts using Microsoft Visual C# 2008.
   The ScriptMain is the entry point class of the script.
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
namespace ST_9a6d985a04b249c2addd766b58fee890.csproj
    [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
        #region VSTA generated code
        enum ScriptResults
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
        #endregion
        The execution engine calls this method when the task executes.
        To access the object model, use the Dts property. Connections, variables, events,
        and logging features are available as members of the Dts property as shown in the following examples.
        To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
        To post a log entry, call Dts.Log("This is my log text", 999, null);
        To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
        To use the connections collection use something like the following:
        ConnectionManager cm = Dts.Connections.Add("OLEDB");
        cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
        Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
        To open Help, press F1.
        public void Main()
            string file = Dts.Variables["User::FolderName"].Value.ToString();
            string[] files = System.IO.Directory.GetFiles(Dts.Variables["User::FolderName"].Value.ToString());
            System.IO.FileInfo finf;
            DateTime currentDate = new DateTime();
            string lastFile = string.Empty;
            foreach (string f in files)
                finf = new System.IO.FileInfo(f);
                if (finf.CreationTime >= currentDate)
                    currentDate = finf.CreationTime;
                    lastFile = f;
            Dts.Variables["User::LastFile"].Value = lastFile;
            Dts.TaskResult = (int)ScriptResults.Success;
thx regards dinesh vv

Similar Messages

  • I get the message  on Apple TV "setting date and time"

    I get the message  on Apple TV "setting date and time", but seems to be stuck in that action. When I check, network settings, everything seems OK.  Any suggestions?

    This will normally happen if you continually turn the AppleTV off at the wall (happens each time you turn it on). If its stuck on that, just turn it completely off, then see if it gets stuck on that again. If it keeps getting stuck (as in for more than 5 minutes) on it, plug it into your computer and attempt to update the AppleTV. You may need to restore it if the software is already up to date or it's still not working after the update.

  • How to get the number of files currently open?

    hi,
    does any one know how to get the number of files currently open in windows OS?
    e.g. lets say .txt files...
    any comment will be really appreciated.
    thanks

    Assuming that you don't want to actually do this from within Java code (which would obviously require native code), here's a utility that will give you a list of which file handles are opened by which processes (on Windows):
    http://www.sysinternals.com/ntw2k/freeware/handle.shtml
    - K

  • Using sender file adapter to read the most current file

    Hi,
    in my sender file adapter , i have to read the latest file- all files in  the source directory are named as <filename><timestamp>.txt . I need to read the file with the latest timestamp (i.e. the most current file )
    How do i configure this using file adapter.
    thanks

    Hi Sreeram,
    thanks for the answer- but i found that the option can only be used with NFS transport protocol. what if i am using FTP ?
    alos, by date option means- files are processed according to their time stamp in the file system, starting with the oldest file.
    However in my case i only want to read the latest file and ignore the older files.
    Thanks

  • How to get the most of PowerBook G3 233Mhz

    its been a while since I dint post on Apple discussions, about one year ago, I was thinking I would get a PowerBook G3 Pismo, one year later evry thing was diffrent, I ordered a 233Mhz PowerBook G3 Wallstreet (It was the only choice with the money I had) and now I really want to know how to get the most out of it.
    I want to do the following
    -Browse the web
    -Listen to music
    -do keynote presentations
    -word proccesing
    -storage
    The powerBook that I am going to get comes with a nice 233Mhz G3 chip, 64MB of RAM a 12 inch screen and running Mac OS 9.2.2 (my favorite).
    I have alot of knowledge on old Macintosh, and I know almost anything if some asks me things about acient macintosh, but you know, some times you need a little help from other mac fans and share your thoughts...
    So what apps should I get? I do know that if you use the commom low requirements apps, It will run smoothly.

    iBook,
    Yes, you can add a USB 1.1 or 2.0 PC card to the PCMCIA/CardBus slot. A few suggestions:
    -Combo FireWire/USB CardBus PC cards do not work well with OS 9.x; either the USB or FireWire port does not work. This is a software problem in 9.x since these combos work fine under 10.x. My suggestion would be to buy a separate USB PC card and/or FireWire PC card for your connectivity.
    -USB 2.0 PC cards will only run at the slower USB 1.1 speeds under 9.x but this is fine for printers, etc. If you wanted to connect an HD, I would use the FireWire interface.
    -FireWire and USB PC cards supply insufficient bus power to power a FireWire or USB HD; any device like a printer or HD will have or should have its own power supply.
    -Since FireWire and USB are not native to the Wallstreet, the necessary USB and FireWire extensions have not been installed. Open your Extensions Mananger and see if you have these extensions:
    USB Mass Storage Extension
    USB Support
    USB Mass Storage Support
    USB Software Locator
    USB Device Extension
    If the above are not present, I recommend you download this USB extension package from OWC; they assembled various version numbers of the Apple USB extensions to correct a problem OS 9.2.2 has with USB PC cards but they can be used with any version of OS 8.6 > 9.2.2.
    http://eshop.macsales.com/tech/ftp/usb/usbextensions.sit
    A file titled 'usbextensions.sit' will appear on your desktop assuming you have set the browser to download files to your desktop. Double-click the file to decompress it and you will have a folder on the desktop with these extensions:
    USB Support v1.4.1
    USB Software Locator v1.5.6
    USB Device Extension v1.5.6
    USB Mass Storage Support v2.0.4
    USB Mass Storage Extension v2.0.4
    Highlight all five extensions, then drag them on top of the closed System Folder icon; they will be automatically installed in the Extensions folder. Before restarting, go to Apple menu > Control Panels > Energy Saver > Advanced Settings and uncheck 'Allow Processor Cycling' for •BOTH• the power adapter and battery. If not unchecked (disabled), the powerbook will freeze with a USB PC card.
    Now restart to make the USB extensions active. Insert the USB PC card; you should see a USB PC card icon on the desktop. Connect a USB mouse (there is sufficient power for it) and test the USB PC card.
    If no desktop USB PC card icon appears, make sure the PC card is fully inserted. You may have to place a hand on the side of the powerbook opposite the PC card slot so you can push hard. If the card fails to seat, the card slot may be in the locked position. Push an opened paperclip into the small hole next to the slot to unlock, then try the card again.
    http://docs.info.apple.com/article.html?artnum=16167

  • [Win VC++ 6.0 ]How to get the number of files count in a folder using VC++ 6.0?

    Hi all,
    Can any one tell how to get the number of files(.EPS) count inside a folder when the folder path is specified in VC++ 6.0?
    Thanks in Advance.
    Regards
    myriaz

    I'm a little confused by the question, but it sounds like you're asking how to count the number of files with a particular extension in a given directory? That's not really an AI SDK question, but it's a fairly easy one to find if you google it. If you're trying to use Illustrator to do it, AI doesn't have a general purpose file API. It has a few functions to do some things that Illustrator needs, but I don't think enumerating directories is one of them.

  • How to provide date and time stamp to the extracted file.

    I 'm downloading data from DB to Flat file using GUI_DOWLOAD. whenever it is executed it is creating with a file name.
    if i rerun the program the file is overwriting with the same name.
    now based on the requirement how many times i executed, that many times file should be individually created and should be added with date and time stamp.
    like
    if when i executed  at the very first time it should saved with filename, date and time.
    say "Address.txt 04/05/2007 07:55:10"
    When i executed it for second time it doesn't overwrite the file.
    it should create a new file.
    like "Address.txt 04/05/2007 07:59:20".
    Please guide me the way if possible code.
    Thanks in advance.

    Hi Vamsi,
                   Use FM 'F4_PROGRAM' to take file from the user .
    In this case user will enter the file name. u can append date & time to that file path.
    Refer this code.
    CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          PROGRAM_NAME  = SY-REPID
          DYNPRO_NUMBER = SYST-DYNNR
        IMPORTING
          FILE_NAME     = P_P_FILE.
    concatenate P_FILE '04/05/2007 07:59:20' into V_FILE.
    CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = v_file
         filetype                        = 'ASC'
          write_field_separator           = 'X'
        TABLES
          data_tab                        = i_tab
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      IF sy-subrc = 0.
        MESSAGE i002.
      ENDIF.
    Reward points if helpful.
    Regards,
    Hemant.

  • How can i get a copy of my ipone messages with the number, date and time stamp?

    How can I get a copy of my iphone messages with the number it was sent from and the date and time stamp?  Needed for court purposes.

    Try the computer apps PhoneView (Mac) or TouchCopy (Mac & PC):
    http://www.ecamm.com/mac/phoneview/
    http://www.wideanglesoftware.com/touchcopy/index.php
    You should probably consult your attorney to see if either of these will be acceptable.

  • Is it possible to get the updated table records based on date & time.

    Is it possible to get the updated table records based on date & time in oracle.
    Thanks in advance.

    no, actually i am asking update records using 'UPDATE
    or DELETE' statement, but not insert statement.
    Is it possible?
    I think we can do using trigger on table, but problem
    is if i am having 20 tables means i have to write 20
    trigger. i don't want like this.Of course it's still possible, typically you'll find applications with a column LAST_UPDATE, probably a LAST_UPDATED_BY and so on column. You don't say what your business need is, if you just want a one of query of updates to particular records and have a recent version of Oracle, then flashback query may well help, if you want to record update timestamps you either have to modify the table, or write some code to store your updates in an audit table somewhere.
    Niall Litchfield
    http://www.orawin.info/

  • How do you edit out the date and time stamp from a photo

    How do you edit out the date and time stamp from a photo

    You can blur it out with retouch
    The built-in "Retouch" brush in "Edit" mode should suffice, if the background is mostly uniform, and if you set the size of the brush to slightly wider than the bar width of the letters. For example, in this picture I removed the year from the date (in the lower right corner) by using the "retouch" brush and following the contours of the letters. (the screen shot is from iPhoto '11, but iPhoto 9 should give similar results).
    Regards
    Léonie

  • The backup file contains unrecognized data and cannot be used

    I am trying to restore files from an NT back up on a SBS 2003.   The backup was taken on this machine and trying to restore to the same.   I get this error: The backup file contains unrecognized data and cannot be used.
    I tried copying it to a different machine with no luck.  Any suggestions?
    Robert

    Hi,
    Since the backup file cannot be restored on a different machine, the backup file could be corrupt. You need to use some third party recovery utilities to restore the backup file.
    For more detailed information, please refer to the article below:
    Windows NTBackup restore troubleshooting tips
    http://searchdatabackup.techtarget.com/tip/Windows-NTBackup-restore-troubleshooting-tips
    Please Note: Since the website is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
    Best Regards,
    Mandy 
    If you have any feedback on our support, please click
    here .
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • PowerShell Script to get the details Like Scope,Last Deployed date and Name for a Solution Deployed in the Farm.

    Hi Experts,
    I am trying to  build a PowerShell Script to get the details Like Scope,Last Deployed date and Name for a Solution Deployed in the Farm.
    Can anyone advise on this please.
    Regards

    Get-SPSolution|Select Name,Scope,LastOperationResult,LastOperationEndTime|Export-CSV "SPInstalledSolutions.csv" -NoTypeInformation
    SPSolution properties
    Get-SPSolution
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • Help adding current Date and Time stamp to file name

    I need help with my script adding current Date and Time stamp to file name.
    This is my file name = myfile.htm
    I would like to save it as = myfile.htm 8/29/2007 11:41 AM
    This is my script:
    <script>
    function doSaveAs(){
         if (document.execCommand){
              document.execCommand('SaveAs','1','myfile.htm')
         else {
              alert("Save-feature available only in Internet Exlorer 5.x.")
    </script>
    <form>
    <input type="button" value="Click here to Save this page for your record" onClick="doSaveAs()"
    </form>
    Thank you

    I agree, I guess I overlooked that!
    I would like to save it as = myfile 8/29/2007 11:41 AM .htm
    I need help with my script adding current Date and Time stamp to file name.
    This is my file name = myfile.htm
    I would like to save it as = myfile 8/29/2007 11:41 AM .htm
    This is my script:
    <script>
    function doSaveAs(){
    if (document.execCommand){
    document.execCommand('SaveAs','1','myfile.htm')
    else {
    alert("Save-feature available only in Internet Exlorer 5.x.")
    </script>
    <form>
    <input type="button" value="Click here to Save this page for your record" onClick="doSaveAs()"
    </form>

  • How do I find the date and time stamp on pictures?

    How do I find the date and time stamp for my pictures?

    The Photos app will not do this but other apps will. iPhoto has an icon that when tapped with the photo open will show the EXIF information you are looking for. iPhoto is not free but you can purchase it in the App Store.
    There may be other photo apps that provide this information as well.
    PhotoForge2 will show the EXIF data as well as the GPS data if it is available.

  • I have an Iphone 4S and I would like to print my text messages, including the thread and the Imessage date and time stamps.  How would I do this?

    I have an Iphone 4S and I would like to print my text messages, including the thread and the Imessage date and time stamps.  How would I do this?

    settings - message - imessage - OFF

Maybe you are looking for