locked
Date field showing date and time RRS feed

  • Question

  • User-13302248 posted
    Hey all, I have a datagrid that gets a date but shows the time as well. How do I show only the date? In the database only the date shows up. Thanks in advance, Rodney
    Wednesday, December 10, 2003 1:11 PM

Answers

  • User595818114 posted
    Hi Rodney, This is a very good date and time formatting article. http://datawebcontrols.com/faqs/CustomizingAppearance/FormatDateTimeData.shtml Hope this helps U. Thanks!
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 10, 2003 1:56 PM

All replies

  • User595818114 posted
    Hi Rodney, This is a very good date and time formatting article. http://datawebcontrols.com/faqs/CustomizingAppearance/FormatDateTimeData.shtml Hope this helps U. Thanks!
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 10, 2003 1:56 PM
  • User-1907454718 posted
    Here's how I do it: <asp:TemplateColumn HeaderText="Required Date"> <ItemTemplate> <%# DataBinder.Eval(Container.DataItem, "ReqDate", "{0:MM/dd/yyyy}") %> </ItemTemplate> <EditItemTemplate> <asp:TextBox id=ReqDate Runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ReqDate", "{0:MM/dd/yyyy}") %>'> </asp:TextBox> </EditItemTemplate> </asp:TemplateColumn>
    Wednesday, December 10, 2003 1:56 PM
  • User-13302248 posted
    Thank you, that worked great. Rodney
    Wednesday, December 10, 2003 2:27 PM
  • User1347510516 posted

    Here's how I do it: <asp:templatecolumn headertext="Required Date"> <itemtemplate> <%# DataBinder.Eval(Container.DataItem, "ReqDate", "{0:MM/dd/yyyy}") %> </itemtemplate> <edititemtemplate> <asp:textbox id="ReqDate" runat="server" text="<%# DataBinder.Eval(Container.DataItem, "ReqDate", "{0:MM/dd/yyyy}") %>"> </asp:textbox> </edititemtemplate> </asp:templatecolumn>

    Hi, Do you know how do I implement this in my code ..... I am using Cascading Dropdowns, and showing date in one of the Dropdowns.

    <asp:DropDownList ID="ddlsdate"  DataTextField= "Course_Start_Date" DataValueField="Course_Id" DataSourceID="SqlDataSource21" runat="server" />

    I think this Dropdown is not databound and hence I can't use Eval or Bind function.

    Plz help.

    Thanks

    Monday, April 25, 2011 12:27 PM
  • User1177242335 posted

    Use this in ur database query

    SELECT CONVERT(VARCHAR(10), GETDATE(), 101) AS [MM/DD/YYYY]

    then u dont have to worry on the aspx page to format.

    Please mark answer if solves problem.

    THanks

    Ahmed

    Monday, April 25, 2011 12:37 PM
  • User1347510516 posted

    Actually, I just added this DataTextFormatString="{0:d}" 

    <asp:DropDownList ID="ddlsdate" DataTextFormatString="{0:d}" DataTextField= "Course_Start_Date" DataValueField="Course_Id" DataSourceID="SqlDataSource22" runat="server" />

    to my Dropdown and it fixed the problem.

    Tuesday, April 26, 2011 1:09 AM