Solved

Formating Date

Posted on 2004-04-23
2
195 Views
Last Modified: 2010-04-24
I have following queery

SELECT DISTINCT Week_ending
FROM         Timesheets
WHERE     (EmployeeID = '1') AND (tsheet_date BETWEEN '2004-01-01' AND '2004-12-31 23:59')

which results in a 3/28/2004 12:00:00 result set when I bind it to listbox...

        ds = New DataSet

        myda.Fill(ds, "AllTables")

        ListBox3.DataSource = ds
        ListBox3.DataSource = ds.Tables(0)
        ListBox3.DataTextField = ds.Tables(0).Columns("Week_ending").ColumnName.ToString()
        ListBox3.DataValueField = ds.Tables(0).Columns("Week_ending").ColumnName.ToString()
        ListBox3.DataBind()
        ListBox3.Items.Insert(0, "All")

I need the result set to be just 3/28/2004, thanks
0
Comment
Question by:gtvingo14
2 Comments
 
LVL 48

Accepted Solution

by:
Mikal613 earned 100 total points
ID: 10900986


SELECT DISTINCT convert(varchar(10),Week_ending,110)
FROM         Timesheets
WHERE     (EmployeeID = '1') AND (tsheet_date BETWEEN '2004-01-01' AND '2004-12-31 23:59')
0
 
LVL 1

Expert Comment

by:warmach
ID: 10918423
If the date being returned is being held in a DateTime typed variable, use the method ToShortDateString()

DateTime d;

d.ToShortDateString();
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Library to convert HTML to PDF. 8 55
Populating an array of locale_time_info 8 37
Vb.net dynamic formulas in runtime 11 61
Allow user to hide and show datagridview columns 4 17
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now