找出公司业务年度的逻辑? [英] Logic to find out company business year ?

查看:70
本文介绍了找出公司业务年度的逻辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii,



我将公司业务数据存储为不存储任何年份的月份和日期。



基于日期和月份我想找出公司当前工作年度



例如,如果公司业务年度设置为1月1日,那么他当前的业务年度为相当于当年是



2014/2015



查找今年数据的任何逻辑



我有日期和月份

Hii ,

I am storing companies business data as month and date not storing any year.

based on date and month i want to find out companies current business year

for example if companies business year is set as 1 april then his current business year is as respective to current year is

2014/2015

any logic to find out this year data

I have date and month

推荐答案

这是你想要的吗?

Is this the sort of thing you want?

int testEndDateMonth = 1;
int testEndDateDay = 20;

//assume end date is in this calendar year
DateTime today = DateTime.Now;
DateTime testDate=new DateTime(today.Year,testEndDateMonth,testEndDateDay);
Console.WriteLine(testDate > today ? "Last Year" : "This Year");


这是解决方案1的SQL等价物。

Here is a SQL equivalent of solution 1.
declare @testEndDateMonth int, @testEndDateDay int;
set @testEndDateMonth = 1;
set @testEndDateDay = 20;

declare @testDate datetime;
set @testDate = convert(varchar(4), datepart(year, getdate()))
						+replace(str(@testEndDateMonth, 2), space(1), '0')
						+replace(str(@testEndDateDay, 2), space(1), '0')
;
select 	
case when @testDate > getdate() then
	'Last Year'
else
	'This Year'
end WhatYear;


这篇关于找出公司业务年度的逻辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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