File Timestamp

  • Hello Everyone

    I am working on a SSIS package that will copy files from one directory to another depending on the file timestamp. I have all that working, but I am having a little problem in comparing the file timestamp with the variable value. My variable value is: 4/10/2008 1:57 PM and the timestamp of the file may be 4/10/2008 1:57:07 and that file will not be copied. I would like to compare only down to the minute, not the seconds.

    I am using C# in a Script task. How can I compare between the variable values? I know how to compare with one variable against the timestamp. But C# does not have a BETWEEN clause like SQL does.

    Does anyone have an idea how I can compare the timestamp from between my mintime and maxtime varaibles? I am always open for anything or a suggestion on a different way to accomplish this.

    Thanks in advance

    Andrew SQLDBA

  • You don't need 'between' when you've got C#! Nor in SQL Server, to be honest - it's just a short cut that can be achieved through other means.

    In pseudo-code:

    (time >= x) and (time < x+1 minute)

    should give you the sort of condition you're looking for.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Thank you Phil

    I just figured it out right after I posted on here.

    What luck, I worked on this all day yesterday, and after walking away from this yesterday and looking at it this morning, I was able to figure it out.

    I will keep your suggestion in mind for other things as well.

    Andrew SQLDBA

  • AndrewSQLDBA (8/24/2010)


    Thank you Phil

    -- and after walking away from this yesterday and looking at it this morning, I was able to figure it out.

    --

    That happens to me all the time. In fact, if I hit a problem after about 2pm, I generally just give up for the day because I know my brain will have the solution by the next morning 😀

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Phil

    What about instead of the file timestamp of a date and time, I want to use only the time. Is there a way to strip off the date and compare only the time?

    Thanks

    Andrew SQLDBA

  • AndrewSQLDBA (8/24/2010)


    Phil

    What about instead of the file timestamp of a date and time, I want to use only the time. Is there a way to strip off the date and compare only the time?

    Thanks

    Andrew SQLDBA

    Here's a VB example (sorry, I don't do C# unless I really have to) that should get you on the right path:

    Public Sub Main()

    Dim RandomDate As DateTime = "4/10/2008 1:57:07"

    Dim Hour As Int16

    Hour = RandomDate.Hour

    MsgBox(Hour)

    Dts.TaskResult = ScriptResults.Success

    End Sub

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply