如何评估 SQL 时间戳?
我有一个中继器控件,我希望它显示在中继器控件的标签旁边。我该怎么做?现在它打印空白字符而不是时间?有什么想法吗?
我的标签看起来像这样;
<asp:Label ID="Label1" runat="server" Text='<%# (Eval("QTime"))%> '></asp:Label>
这给了我一个类似“”AAAAAAAALuE=”的输出。我认为这里需要进行转换,我想知道如何使用辅助函数或其他东西来做到这一点。
注意:时间戳来自 MS SQL 数据库字段“时间戳”
谢谢
I am having a repeater control and I want it to be displayed in side a label in the repeater control. How do I do that ? For now it is printing blank characters instead of the time ? any ideas ?
The label I have looks like this ;
<asp:Label ID="Label1" runat="server" Text='<%# (Eval("QTime"))%> '></asp:Label>
this is giving me an output like ""AAAAAAAALuE=". I think a conversion is needed here , and I want to know how to do that say using a helper function or something.
NOTE: The timestamp is coming from MS SQL Database field "timestamp"
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法从 SQL Server 上的
TIMESTAMP
列获取DateTime
。来自 MSDN - 时间戳 (Transact-SQL):
正是因为这种混乱,这种类型在SQL Server 2005之后的版本中被重命名为
rowversion
。timestamp
/rowversion
只是判断行数据是否已更改的方法 - 它们与日期或时间没有任何关系。您需要改用
DateTime
数据类型。You can't get a
DateTime
from aTIMESTAMP
column on SQL Server.From MSDN - timestamp (Transact-SQL):
This type was renamed to
rowversion
in version later than SQL Server 2005 exactly because of this kind of confusion.timestamp
/rowversion
are simply ways to tell whether the row data has changed - they do not have any relation to the date or time.You need to use a
DateTime
data type instead.