mgmhicks
asked on
formating date for combo box
I have this code
cboPayPeriod.DataSource = myDS.Tables(1)
cboPayPeriod.DisplayMember = Format("BeginDate", "mm/dd/yy")
of course not getting the format results I was looking for. Without format I receive the dates with the time as well. 04/29/04 12:00:00AM. I only want the date. How can I format in the combo box.
thanks
cboPayPeriod.DataSource = myDS.Tables(1)
cboPayPeriod.DisplayMember
of course not getting the format results I was looking for. Without format I receive the dates with the time as well. 04/29/04 12:00:00AM. I only want the date. How can I format in the combo box.
thanks
ASKER
Yea that probably works put how to I get that in the line
cbopayperiod.displaymember = "the data in the format I want"
cbopayperiod.displaymember
cboPayPeriod.DataSource = myDS.Tables(1)
'If your BeginDate is of type DateTime
'Then you can use this code:
cboPayPeriod.DisplayMember
ASKER
begindate has to be in quotes or I get a error.
you can use this:
Dim strdate as string
Dim dtNow As DateTime = DateTime.Now
MsgBox(dtNow) 'Before Formatting
strdate = String.Format("{0:d}", dtNow)
MsgBox(strdate) 'After Formatting
Please Note : you have to pass parameter of type DateTime.
It will work fine.
Dim strdate as string
Dim dtNow As DateTime = DateTime.Now
MsgBox(dtNow) 'Before Formatting
strdate = String.Format("{0:d}", dtNow)
MsgBox(strdate) 'After Formatting
Please Note : you have to pass parameter of type DateTime.
It will work fine.
What is the data source (Access, SQL Server, Oracle)? There are functions on the DBMS side that can format the data as specified, but they differ depending on the system.
Bob
Bob
ASKER
the database is sql
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
r you using any stored procedure to get data in your scenario.
if yes show your stored proc code. we can take a look.
Also your front end code. It will help to solve your problem
Dim dtNow As DateTime = DateTime.Now 'Your date with time before formatting
strdate = dtNow.ToShortDateString 'Your date after formatting (mm/dd/yyyy).
Thanks