c# - 如何在 Web 表单应用程序中获取最后日期输出?
问题描述
我的任务是制作一个 Web 表单应用程序,用户输入一个日期,应用程序返回该月的最后一个日期作为输出。请帮助我构建它。我必须使用 EOMONTH 吗?
DECLARE @date DATETIME = '12/1/2011';
SELECT EOMONTH ( @date ) AS Result;
GO
我是一个绝对的初学者。如果你告诉我一步一步的过程,这对我来说意义重大。
解决方案
参考DateTime 类,DateTime.TryParse,DateTime.ToString,TextBox 类,标签类
DateTime tempDate;
if (DateTime.TryParse(userInputTextBox.Text, out tempDate))
{
DateTime newDate = new DateTime(tempDate.Year, tempDate.Month, DateTime.DaysInMonth(tempDate.Year, tempDate.Month));
endOfMonthLabel.text = newDate.ToString("mm/dd/yyyy");
}
else
{
endOfMonthLabel.text = "invalid date format";
}
推荐阅读
- typescript - Vue 类型脚本 - 数据和自定义类型
- android - Android studio Kotlin 多个按钮打开多个activity
- sql - 从具有 NULL 值的表中创建 DISTINCT 用户列表
- java - 从 Java 收集的 SharedFlow 不起作用
- c++ - 助记符和自定义小部件
- windows-subsystem-for-linux - FAT[0000] 无效配置:未提供配置
- build - 使用 tar 源以外的其他名称构建 RPM 文件
- maps - 如何禁用从 Google 我的地图中对地图嵌入代码的公开访问?
- integration - EarlGrey 与 Allure 报告的集成
- javascript - 如何在 json 解析根目录中分配变量?