Posts

Showing posts from January, 2013

how to get week number for a date based on month from the date in sql server

  We have a date column in a table and I want to get week number for that particular date based on the month from that date irrespective of the day For example: 01 - dec-2012 to 07 - dec-2012 should give week number as 1 08 - dec-2012 to 14 - dec-2012 should give week number as 2 15 - dec-2012 to 21 - dec-2012 should give week number as 3     You can use DAY (Transact-SQL)   select ( ( day ( ColumnName ) -1 ) / 7 ) + 1 as W   Example :   select ( ( day ( '2012-11-01 00:00:00.000' ) -1 ) / 7 ) + 1 as W   Output :   W -- 1

Dictionary Class Demo in C#

The Dictionary < TKey, TValue > generic class provides a mapping from a set of keys to a set of values. Each addition to the dictionary consists of a value and its associated key. Retrieving a value by using its key is very fast, close to O(1), because the Dictionary < TKey, TValue > class is implemented as a hash table. As long as an object is used as a key in the Dictionary < TKey, TValue > , it must not change in any way that affects its hash value. Every key in a Dictionary < TKey, TValue > must be unique according to the dictionary's equality comparer. A key cannot be null , but a value can be, if the value type TValue is a reference type. Dictionary < TKey, TValue > requires an equality implementation to determine whether keys are equal. You can specify an implementation of the IEqualityComparer < T > generic interface by using a constructor that accepts a comparer parameter; if you do not specify an implementation, the default