如何显示过帐日期 [英] how to display posting date

查看:78
本文介绍了如何显示过帐日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


现在,我创建一个网站,用户在其中提交一些项目.现在我想当用户看到提交项目时显示什么时间,然后在提交项目时显示哪个时间之前提交的代码项目,例如codeproject网站.

Hi,
Now i create a website where user submit the some item. Now i want to when user see submit item then display which time ago submit item like codeproject site when we submit any item then display when submit. how to implement.

推荐答案

首先存储用户输入时,请将当前日期和时间存储在SQL Date字段中.
显示时,检索信息.

不能更具体,不知道您的网站如何运作...



但是如何显示昨天发布的内容."

使用TimeSpan:从当前日期(DateTime.Now)中减去发布的日期,然后检查Days属性.如果为零,则今日发布".如果是一个,则昨天发布".如果需要,可以很容易地计算出上周",上个月"等.
When you store the user input in the first place, store the current date and time in an SQL Date field.
When you display it, retrieve the information.

Can''t be more specific, don''t know how your site works...



"but how to display posted yesterday."

Use a TimeSpan: subtract the date posted from the current date (DateTime.Now) and check the Days property. If it is zero, the "posted Today". If it is one, then "posted Yesterday". Simple to work out "last week", "last month" and so on if you need it.


Take one field into your table as PostedDate or any Name <br />
and set its Default value getDate()<br />
it will automatically add exact date and time of you stored Data <br />
then at the time of retrieving just calculate that according to your Requirement.


制作表格并将列设为postedDate并将其数据类型设置为
Datetime并将默认值设置为getdate().

现在将查询运行为:

Make a table and take a column as postedDate and set its data type as
Datetime and set default value as getdate().

now run this query as:

select datediff(d,postedDate ,getdate()) as DayOlder from tablename


这篇关于如何显示过帐日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆