?
Solved

Formating Date

Posted on 2004-04-23
2
Medium Priority
?
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 48

Accepted Solution

by:
Mikal613 earned 400 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

719 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