DateAdd函数-神秘问题 [英] DateAdd Function - Mysterious Problem

查看:107
本文介绍了DateAdd函数-神秘问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我在ASP.NET网站的两个地方使用以下代码.

1.在网页的按钮"中,单击事件"
2.在网站的模块中定义为功能

使用的代码:

Dear All,

I am using the following code in two places in my ASP.NET Website.

1. In the Webpage - In Button.Click Event
2. Defined as a Function in a module in the website

Code Used:

Dim n as Date
n = DateAdd(DateInterval.Month, 1, Now())
Msgbox ("Now it is " & now() & ", Due Date is " & n)


在情况1中执行此代码时,我得到以下输出
现在是2012年11月25日14:35:00,截止日期是2012年12月25日14:35:00

但是当在情况2中执行相同的代码时,我得到以下输出
现在是11/25/2012 14:35:00,截止日期是12:00:00

请告诉我我要去哪里错了.

谢谢和问候.

添加了代码块[/编辑]


When this code is executed in situation 1, I get the following output
Now it is 11/25/2012 14:35:00, Due Date is 12/25/2012 14:35:00

But when the same code is executed in situation 2, I get the following output
Now it is 11/25/2012 14:35:00, Due Date is 12:00:00

Pl advice where I am going wrong.

Thanks and regards.

Code block added[/Edit]

推荐答案

您是否尝试调试并查看n中有什么值?

您可以尝试使用ToString函数,如下所示:
Have you tried to debug and see what value comes in n?

You can try using ToString function as follows:
Msgbox ("Now it is " & now().ToString("dd/MM/yyyy") & ", Due Date is " & n.ToString("dd/MM/yyyy"))


这篇关于DateAdd函数-神秘问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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