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

mgmhicksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mani_saiCommented:
Try This:

Dim dtNow As DateTime = DateTime.Now  'Your date with time before formatting

strdate = dtNow.ToShortDateString  'Your date after formatting (mm/dd/yyyy).


Thanks



0
mgmhicksAuthor Commented:
Yea that probably works put how to I get that in the line


cbopayperiod.displaymember = "the data in the format I want"
0
mani_saiCommented:


cboPayPeriod.DataSource = myDS.Tables(1)

'If your BeginDate is  of type DateTime

'Then you can use this code:

cboPayPeriod.DisplayMember = BeginDate.ToShortDateString  

0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

mgmhicksAuthor Commented:
begindate has to be in quotes or I get a error.

0
mani_saiCommented:
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.
0
Bob LearnedCommented:
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
0
mgmhicksAuthor Commented:
the database is sql
0
Bob LearnedCommented:
With SQL Server, you can format the date using the CONVERT function:

Examples:

Working with SQL Server Date/Time Variables: Part Two - Displaying Dates and Times in Different Formats
http://www.databasejournal.com/features/mssql/article.php/2197931

Date and Time Manipulation in SQL Server 2000
http://www.sqljunkies.com/HowTo/6676BEAE-1967-402D-9578-9A1C7FD826E5.scuk


Bob
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mani_saiCommented:

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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.