• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 480
  • Last Modified:

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

0
mgmhicks
Asked:
mgmhicks
  • 4
  • 3
  • 2
1 Solution
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now