显示下一年并通过

编程入门 行业动态 更新时间:2024-10-23 15:21:05
本文介绍了显示下一年并通过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个下拉,我正在展示2006年3月31日和过去的5年,我需要 也显示下一年的月末,仍然显示已通过5 。 所以我需要12/31/2007并且从今天起5年后,我怎么能这样做?

I have a drop down where I''m showing 3/31/2006 and the passed 5 years, I need to also show month end for the following year and still show the passed 5 . So I need 12/31/2007 and back 5 years from today, how can I do this?

推荐答案

你好CSharpguy - 如果我理解你的问题,我会认为 DateTime是你的朋友。您可以使用DateTime对象,然后调用 适当的方法.AddDays(),. AddMonths()或AddYears() - 添加否定 数字以向后移动。它会为你做所有日历的东西。 - brians www.limbertech " CSharpguy"写道: Hello CSharpguy - If I understand your question correctly, I would think that DateTime is your friend. You can use a DateTime object and then call the appropriate method .AddDays(), .AddMonths(), or AddYears() - add negative numbers to go backwards. It will do all the all the calendar stuff for you. -- brians www.limbertech "CSharpguy" wrote: 我有一个下拉,我正在展示2006年3月31日和过去的5年,我需要也显示月结束以下今年仍然显示已通过的5。 所以我需要12/31/2007并且从今天起5年后,我该怎么做? I have a drop down where I''m showing 3/31/2006 and the passed 5 years, I need to also show month end for the following year and still show the passed 5 . So I need 12/31/2007 and back 5 years from today, how can I do this?

DateTime.AddYears(int value)方法怎么样? 您可以使用循环将变量年份作为参数传递给 此方法并将该日期添加到下拉列表中。传递一个负值 值,返回一年,正值将增加一年。 What about the DateTime.AddYears(int value) Method? You can use a loop to to pass in a variable year as the parameter to this method and add that date to the dropdown list. Passing a negative value with go back a year, and a positive value will add a year.

你想玩使用system.DateTime类。例如 System.DateTime.Now.AddYears(1)将返回今天的DateTime对象 明年的日期 System.DateTime.Now.AddYears(-3)将从3年前返回一个DAtTime。 " CSharpguy"写道: You want to play with the system.DateTime class. E.g. System.DateTime.Now.AddYears(1) will return a DateTime object that is todays date next year System.DateTime.Now.AddYears(-3) will return a DAtTime from 3 years ago. "CSharpguy" wrote: 我有一个下拉,我正在展示2006年3月31日和过去的5年,我需要也显示月结束以下今年仍然显示已通过的5。 所以我需要12/31/2007并且从今天起5年后,我该怎么做? I have a drop down where I''m showing 3/31/2006 and the passed 5 years, I need to also show month end for the following year and still show the passed 5 . So I need 12/31/2007 and back 5 years from today, how can I do this?

更多推荐

显示下一年并通过

本文发布于:2023-10-28 23:30:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538082.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!