March 15, 2011 at 10:36 am
Mid(day(date) + 100,2,2)help me in understanding this plz...i am new to this kind of stuff...help me plz
March 15, 2011 at 10:41 am
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
March 15, 2011 at 10:41 am
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)
March 15, 2011 at 10:44 am
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
March 15, 2011 at 3:19 pm
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