Help me in understanding this

  • Mid(day(date) + 100,2,2)help me in understanding this plz...i am new to this kind of stuff...help me plz

  • Its adding 100 to the day and then taking the last two values.

    Where i think this is being used for , is to convert single figure days (eg, 1,2,3,4 etc..) to two figure days (01,02,03,04 etc..) with a leading 0

    this is quite common as a lot of dates need to have two figures, but when you use the day and month functions it will 1 figure for values below 10

  • quillis131 (3/15/2011)


    Mid(day(date) + 100,2,2)help me in understanding this plz...i am new to this kind of stuff...help me plz

    Assuming vb6 transposes to ssis :

    day(date) would be 15 today.

    so that makes it mid(115, 2, 2)

    That means start at 2nd character and take 2 characters. Which then returns 15 again here. But now it's a string, and not an int.

    Now try again on the 9th and this will return 09 (string) rather than 9 (int)

  • Take the current day (of the month) and add 100 to it.

    Then, starting at the second character, take two characters.

    It looks to me like they are trying to get a zero-filled day. That is usually done like:

    RIGHT("00" + string(day(date)), 2)

    (Note: I don't remember the proper conversion to a string, so I'm not sure that "string" is correct above.)

    Edit: and I see that several of us jumped on it all at once, with the same conclusions.

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

  • Thank u all

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

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