displaying a date w/o the time trail

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vstud
    New Member
    • May 2008
    • 17

    displaying a date w/o the time trail

    Hi,

    I'm using the datagrid view to display transactions. (asp .net 2.0),
    one of the bound fields is DateTime type, when displayed on the grid view it shows the full field with it's time stamp i.e. 3/3/2008 12:00:00 AM.

    my question is how can i strip it down and only show the date part it on the grid.

    hope it make sense.

    TIA
  • dip_developer
    Recognized Expert Contributor
    • Aug 2006
    • 648

    #2
    if you are fetching date from database write a query like

    select convert(varchar ,dateColumnName ,101) from tablename

    or you can convert the date to short date string like...

    Convert.ToDateT ime(yourDateVAl ue).ToShortDate String()

    this will display only the date

    Comment

    • vstud
      New Member
      • May 2008
      • 17

      #3
      thanks for the reply.

      I'm not sure when it's not working for me when i use it inside the asp page.
      I'm getting an error on the convert or what ever function. for example:

      <asp:AccessData Source ID="AccessDataS ourceID" runat="server" DataFile="c:\as p\trx_DB.mdb"

      OnSelecting="Ac cessDataSourceI D_Selecting" SelectCommand=" SELECT web_trx.order_n umber, web_trx.order_d ate, DateValue( web_trx.trx_dat e), activation_code s.id_code, activation_code s.activation_co de FROM (web_trx INNER JOIN activation_code s ON web_trx.activat ion_code_id = activation_code s.id_code) WHERE (web_trx.order_ date BETWEEN ? AND ?) ORDER BY web_trx.order_d ate">

      <SelectParamete rs>

      <asp:FormParame ter DefaultValue="0 1/01/2005" FormField="txtF romDate" Name="Fromdate"

      Type="DateTime" Size="30" />

      <asp:FormParame ter DefaultValue="0 1/01/2009" FormField="txtT oDate" Name="Todate"

      Type="DateTime" Size="30" />

      </SelectParameter s>

      </asp:AccessDataS ource>


      the code snip will return an error, however if i take the function part out, aka,
      DateValue( web_trx.trx_dat e) all is fine.

      any idea why? Do i need to write a c# or Vb seperate function to handle it..?

      TIA

      Comment

      • CyberSoftHari
        Recognized Expert Contributor
        • Sep 2007
        • 488

        #4
        above solution by dip_developer will need c# or Vb seperate function and also refer Problem converting a string into date in vb.net

        Comment

        Working...