Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Formating Date

Posted on 2004-04-23
2
Medium Priority
?
203 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 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Screencast - Getting to Know the Pipeline

782 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