英文:
how to get financial year in asp.net web form in textbox automatically
问题
如何在ASP.NET Web表单中自动在文本框中获取财政年度。我在ASP.NET中有一个文本框,如何自动显示财政年度。示例:2019-2020(4月1日至3月31日)。
英文:
how to get financial year in asp.net web form in Textbox automatically. i have a textbox in asp.net how to show financial year automatically. 2
exp; 2019-2020 (1 april to 31 march)
答案1
得分: 2
这是您的答案,
DateTime dateTime = DateTime.Now;
string fiscalyear;
if (dateTime.Month >= 4)
{
fiscalyear = dateTime.Year + " - " + (dateTime.Year + 1);
}
else
{
fiscalyear = (dateTime.Year - 1) + " - " + dateTime.Year;
}
textbox1.Text = fiscalyear;
英文:
Then here is your answer,
DateTime dateTime = DateTime.Now;
string fiscalyear;
if (dateTime.Month >= 4)
{
fiscalyear = dateTime.Year + " - " + (dateTime.Year + 1);
}
else
{
fiscalyear = (dateTime.Year - 1) + " - " + dateTime.Year;
}
textbox1.Text = fiscalyear;
答案2
得分: 0
我找到了帮助我的解决方案:
textbox1.Text = DateTime.Now.Year.ToString();
英文:
i found the solution which help me:
textbox1.Text = DateTime.Now.Year.ToString();
答案3
得分: 0
DECLARE @FIYear VARCHAR(20)
SELECT @FIYear = (CASE WHEN (MONTH(GETDATE())) <= 3 THEN convert(varchar(4), YEAR(GETDATE())-1) + ''-'' + convert(varchar(4), YEAR(GETDATE())%100)
ELSE convert(varchar(4),YEAR(GETDATE()))+ ''-'' + convert(varchar(4),(YEAR(GETDATE())%100)+1)END)
SELECT @FIYear AS F_YEAR
英文:
use this query
DECLARE @FIYear VARCHAR(20)
SELECT @FIYear = (CASE WHEN (MONTH(GETDATE())) <= 3 THEN convert(varchar(4), YEAR(GETDATE())-1) + '-' + convert(varchar(4), YEAR(GETDATE())%100)
ELSE convert(varchar(4),YEAR(GETDATE()))+ '-' + convert(varchar(4),(YEAR(GETDATE())%100)+1)END)
SELECT @FIYear AS F_YEAR
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论