获取TSQL的当前年份 [英] Get current year in TSQL
本文介绍了获取TSQL的当前年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些数据正在尝试提供报告,并且正在处理年初至今报告。我在表中的列的格式设置为日期时间。我试图运行select语句以获取日期=今年的所有结果。
I have data I am trying to pull for a report and I am working on a Year to Date report. My columns in the table are formatted as datetime. I am trying to run a select statement to get all the results where date = this year.
例如:
SELECT A.[id], A.[classXML]
FROM tuitionSubmissions as A
WHERE A.[status] = 'Approved' AND A.[reimbursementDate] = THISYEAR
FOR XML PATH ('data'), TYPE, ELEMENTS, ROOT ('root');
是否有简便的方法来完成此操作?
Is there an eay way to acomplish this?
推荐答案
是的,实际上非常简单:
Yes, it's remarkably easy in fact:
WHERE YEAR(A.[reimbursementDate]) = YEAR(GETDATE())
这篇关于获取TSQL的当前年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文