Solved

Formating Date

Posted on 2004-04-23
2
198 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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 …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

830 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