Sunday, March 11, 2012

Date Formatting in Drop Down List

I am trying to make a dropdownlist with a date. Where should I definethat I do want only the date, not the hour.
So far it shows somethinglike "14-02-2006 0:00:00" whereas I just want "14-02=2006". I tried"CAST(CONVERT (varchar(25); Ma_Fecha; 112) AS datetime)" in the SQLStatement but it doesnt seem to work.

[CODE]
Dim sSQL As String = " SELECT "
sSQL = sSQL & " Ma_Date,sDate "
sSQL = sSQL & " FROM vwMareaMain "
Dim comm As New SqlCommand(sSQL, objConn)
Dim dataAdapter As New SqlDataAdapter(comm)
dataAdapter.Fill(objDS2, "vwDate")

Me.cboDate.DataMember = "vwDate"
Me.cboDate.DataValueField = "Ma_Date"
Me.cboDate.DataSource = objDS2.Tables("vwDate").DefaultView
[/CODE]

do aCONVERT(varchar,datecolumn,101)

|||

me.cbodate.datatextfield="Ma_Date"

me.cbodate.datatextformatstring="{0:d}" or perhaps just "{d}"

No comments:

Post a Comment