formatting dates

Results 1 to 2 of 2

Thread: formatting dates

  1. #1
    Join Date
    Dec 1969

    Default formatting dates

    i need the correct syntax for outputting a date to to the browser in the following format:<BR>m/dd/yyyy<BR>-----------------------------------------------------------------<BR>currently, i am using the following syntax for a line in a repeater control:<BR>&#060;tr&#062;&#060;td&#062;<BR>&#060; %# DataBinder.Eval(Container.DataItem, "EventDate") %&#062;<BR>&#060;/td&#062;&#060;/tr&#062;<BR>-----------------------------------------------------------------<BR>this current syntax is outputing the following date format:<BR><BR>2/15/2003 12:00:00 AM <BR>-----------------------------------------------------------------<BR>as you can see, i want to remove the part that specifies the time. can anyone show me how to fix my syntax above so that the date gets output in m/dd/yyyy format without the time?<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: formatting dates

    &nbsp;<BR><BR>DateTime x = DateTime.Now;<BR><BR>x.ToString("MM/dd/yy"); <BR>...........<BR>This is variable x cast to string with argument "Format String"<BR><BR>You will have to access the "EventDate" object of the DataBinder. Your best bet is to use the onDataBinding event of the datagrid, or repeater.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts