Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.

I have one problem that I need the load data from my Sql table into dropdownlist. Data is in date format. I need to load the data in yyyy-MM-dd format without time.

Here is my code

Dim ds As New DataSet
Dim SqlAdp As SqlDataAdapter = New SqlDataAdapter("Select dateofmonthly from PaidDetails where SID='" & Me.txtRegNo.Text & "' and Statuspay='N' order by Nomonths", conn)
SqlAdp.Fill(ds)

Me.cbodate.DataSource = ds.Tables(0).DefaultView
Me.cbodate.DataValueField = "dateofmonthly"
Me.cbodate.DataBind()

conn.Close()

dateofmonthly is in date formate with time. I need date format in dropdown like 2013-10-25

Please help me

Maideen
Posted
Comments
syed shanu 25-Aug-13 21:21pm    
Check with Date format in MYSQL
Select DATE_FORMAT(dateofmonthly, '%Y%m%d') from PaidDetails where SID=

1 solution

Dim SqlAdp As SqlDataAdapter = New SqlDataAdapter("Select convert(datatime,dateofmonthly,101) from PaidDetails where SID='" & Me.txtRegNo.Text & "' and Statuspay='N' order by Nomonths", conn)



for your required format yyyy-MM-dd you may change 101 to 100 or 102 like this
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900