How to select date from datetime in MSSQL

To select date from datetime in MSSQL you can use the following snippet.

Sample MSSQL

SELECT CONVERT(VARCHAR(10),Testdatecolumn,104) FROM dbo.tblTest

The 104 is for tt.mm.jjjj, a list of formats can be found at the MSDN CAST and CONVERT (Transact-SQL)

Please rate this snippet

How to make a List or Collection of class read-only in C# and VB.NET

To make a List or Collection of class read-only in C# and VB.NET you can use the following snippet.

Sample C#

public class Test
{
	private readonly List<int> _testList = new List<int>();

	public IList<int> TestList 
	{
		get { return _testList.AsReadOnly(); }
	}

	public Test()
	{
		_testList.Add(0);
		_testList.Add(1);
		_testList.Add(2);
		_testList.Add(3);
		_testList.Add(4);
		_testList.Add(5);
	}
}

Sample VB.NET

Public Class Test
	Private ReadOnly _testList As New List(Of Integer)()

	Public ReadOnly Property TestList() As IList(Of Integer)
		Get
			Return _testList.AsReadOnly()
		End Get
	End Property

	Public Sub New()
		_testList.Add(0)
		_testList.Add(1)
		_testList.Add(2)
		_testList.Add(3)
		_testList.Add(4)
		_testList.Add(5)
	End Sub
End Class

Please rate this snippet

How to make input numeric only in jQuery

To make input numeric only in jQuery you can use the following snippet.

Sample jQuery

$('input.numbersOnlyinput').bind('keypress', function(input) {   
    return (input.which === 0 || input.which === 8 || (input.shiftKey === false && (input.which < 58 && input.which > 47))) ? true : false;   
}

Please rate this snippet