如何在vb.net中更改DateTimePicker的日期格式,以便以dd/mm/1990格式显示日期,而不带任何时间值?我尝试将格式更改为“短”,虽然这提供了所需的日期格式,但它并没有删除时间。
如何在vb.net中更改DateTimePicker的日期格式,以便以dd/mm/1990格式显示日期,而不带任何时间值?我尝试将格式更改为“短”,虽然这提供了所需的日期格式,但它并没有删除时间。
您需要将DateTimePicker的格式设置为自定义(Custom),然后分配CustomFormat。
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
DateTimePicker1.Format = DateTimePickerFormat.Custom
DateTimePicker1.CustomFormat = "dd/MM/yyyy"
End Sub
dateTimePicker.Value.ToString("yyyy/MM/dd")
试试这段代码,它可以正常工作:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CustomeDate As String = ("#" & DOE.Value.Date.ToString("d/MM/yyyy") & "#")
MsgBox(CustomeDate.ToString)
con.Open()
dadap = New System.Data.OleDb.OleDbDataAdapter("SELECT * FROM QRY_Tran where FORMAT(qry_tran.doe,'d/mm/yyyy') = " & CustomeDate & "", con)
ds = New System.Data.DataSet
dadap.Fill(ds)
Dgview.DataSource = ds.Tables(0)
con.Close()
dd
来表示日期,则在选择1至9时它将返回空值,因此请使用d
进行选择。'Date time format
'MMM Three-letter month.
'ddd Three-letter day of the week.
'd Day of the month.
'HH Two-digit hours on 24-hour scale.
'mm Two-digit minutes.
'yyyy Four-digit year.
文档中包含了日期格式的完整列表。