如何在ASP.NET Web表单中自动获取财政年度并显示在文本框中。

huangapple go评论58阅读模式
英文:

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

huangapple
  • 本文由 发表于 2020年1月6日 15:36:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/59608279.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定