如何仅提取日期(而不是时间)并在报告中使用日期? [英] How do I extract just the date (not the time) and use the date in a report?

查看:138
本文介绍了如何仅提取日期(而不是时间)并在报告中使用日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Form,其上有一个DatePicker类型字段,用户输入日期。然后将日期存储在Access数据库表中。表格中的字段格式化为短日期。



问题是,当我根据表单输入创建报表时,会显示日期和时间。我想在没有时间元素的情况下只显示我的报告中的日期。



如何仅提取报告的日期部分?我相信我需要一个功能来实现这一目标。函数是什么,我在哪里放置函数以使报表中的日期排除时间元素?

I have a Form that has a DatePicker type field on it where the user enters the date. The date is then stored in an Access database table. The field in the table is formatted as a short date.

The problem is that when I create a report based on the input from the form, the date and time appears. I want to have just the date to appear in my report without the time element.

How do I extract just the date portion for my report? I believe I need a function to accomplish this. What would the function be, and where do I put the function so that the date in the report excludes the time element?

推荐答案

请参阅:https://msdn.microsoft.com/en-us/library/system .datetime.date%28v = vs.110%29.aspx [ ^ ]。



-SA


感谢您的回复。我已经阅读了你在我原帖的答案中引用的文章,我创建了以下函数将长日期转换为短日期。



但是,如何将日期显示在报告中作为短日期(仅限日期没有时间部分)?我需要报告中显示的数据库中每条记录的每个日期显示为mm / dd / yyyy格式的短日期。如何使用以下函数转换日期,使它们没有时间部分?我必须有一些简单的东西。



我们将非常感谢任何帮助。



Thanks for the response. I have read the article that you referenced in your answer to my original post, and I have created the below function to convert a long date to a short date.

But, how do I get the dates to appear in my report as a short date (date only no time portion)? I need each date for each record in the database that appears on the report to appear as a short date in the "mm/dd/yyyy" format. How do I use the below function to convert the dates so they don't have the time portion? There must be something simple that I am overlooking.

Any help in this matter will be greatly appreciated.

Public Function DateShort(ByVal Mydate As Date) As String
       Mydate = Mydate.ToString("d")
       Return Mydate
   End Function


(我是这个帖子的原始海报。)我现在意识到要获得以短日期格式(mm / dd / yyyy)在报告中显示的日期,我所要做的就是右键单击 Report.rdlc 设计界面a然后选择占位符属性... ,然后选择数字,然后选择日期,最后选择我想要的日期格式。



完成所有这些操作后,我的报告中的日期将不再显示长日期和时间格式,但会显示短日期格式而没有时间。



我希望这可能有助于其他一些提出相同问题的新手。
(I am the original poster of this thread.) I realize now that to get the dates to appear in my report in the short date format (mm/dd/yyyy), all I have to do is right-click the date field in the Report.rdlc design screen and select Placeholder Properties... and then select Number and then select Date, and finally select the date format I want.

After doing all of that, the dates in my report will no longer display the long date and time format, but will display the short date format without the time.

I hope this might help some other newbie that comes up with the same issue.


这篇关于如何仅提取日期(而不是时间)并在报告中使用日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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