日期格式化

1.在SQL中实现:

  
    
SELECT EmployeeNo,EmployeeName,ProjectCode,ProjectName,CCC,
  CONVERT ( VARCHAR ( 10 ),InDate, 120 ) InDate, CONVERT ( VARCHAR ( 10 ),OutDate, 120 )OutDate
FROM SERP.JPSerp.AMS.AMS_EmployeeProject

 2.页面绑定时:

  
    
< asp:Label ID ="LabelDate" runat ="server" Text ='<%# Bind("start_off_date","{0:MM/dd/yyyy}")% > '> </ asp:Label >

3.服务器端格式化:

  
    
string startDate = Convert.ToDateTime(dtExpectTicket.Rows[i][ " start_off_date " ].ToString()).ToString( " MM/dd/yyyy " ).Replace( @" - " , @" / " );

你可能感兴趣的:(日期格式化)