简体   繁体   English

如何仅在vb.net中显示日期

[英]How to display date only in vb.net

I need to display date only in vb.net. 我只需要在vb.net中显示日期。 These are the steps I went through. 这些是我经过的步骤。

  1. added date to sql database. 添加日期到SQL数据库。 (sql database shows 2013-12-13) (sql数据库显示2013-12-13)
  2. created a table to view it. 创建了一个表格进行查看。 (shows 12/13/2013 12:00:00 AM) (显示12/13/2013 12:00:00 AM)

the methods i've used are: 我使用的方法是:

<%=Formatdatetime(f_purchasedate,2)%>
<%=FormatDateTime(f_purchasedate, "Short Date")%>
<%Response.Write(FormatDateTime(f_purchasedate, 2))%>

Please help. 请帮忙。 Thanks 谢谢

EDIT: Was looking at the wrong place. 编辑:正在看错地方。 this <%=Formatdatetime(f_purchasedate,2)%> works. 此<%= Formatdatetime(f_purchasedate,2)%>有效。 Thanks for the help guys 谢谢你们的帮助

Try This 尝试这个

<%=Formatdatetime(f_purchasedate,2)%>
<%=FormatDateTime(f_purchasedate, "Short Date")%>
<%Response.Write(FormatDateTime(f_purchasedate, DateFormat.ShortDate))%>

OR 要么

 <%Response.Write(f_purchasedate.ToString("yyyy-MM-dd")))%>
f_purchasedate.ToString("d")

请参阅: http : //msdn.microsoft.com/en-us/library/az4se3k1%28v=vs.110%29.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM