In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces how to generate a date list in MSSQL. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
The code is as follows: if exists (select * from dbo.sysobjects where id = object_id (N' [dbo]. [f_getdate]') and xtype in (NumberFN, NFN, NFF') drop function [dbo]. [f_getdate] GO create function [dbo]. [f_getdate] (@ year int,-- the year to be queried @ bz bit-- @ bz=0 query working day, @ bz=1 query rest day @ bz IS NULL query all dates RETURNS @ re TABLE (Date datetime,Weekday nvarchar (3)) as begin DECLARE @ tb TABLE (ID int, Date datetime) insert @ tb select number, dateadd (day,number,DATEADD (Year,@YEAR-1900,'1900-1-1')) from master..spt_values where type='P' and number between 0 and 366 DELETE FROM @ tb WHERE Date > DATEADD (Year,@YEAR-1900,'1900-12-31') IF @ bz=0 INSERT INTO @ re (Date,Weekday) SELECT Date,DATENAME (Weekday Date) FROM @ tb WHERE (DATEPART (Weekday,Date) + @ @ DATEFIRST-1)% 7 BETWEEN 1 AND 5 ELSE IF @ bz=1 INSERT INTO @ re (Date,Weekday) SELECT Date,DATENAME (Weekday,Date) FROM @ tb WHERE (DATEPART (Weekday,Date) + @ @ DATEFIRST-1)% 7 IN (0mai6) ELSE INSERT INTO @ re (Date,Weekday) SELECT Date,DATENAME (Weekday,Date) FROM @ tb RETURN end go select * from dbo.[ f _ getdate] ('2009 Zero)
On how to generate the date list in MSSQL to share here, I hope the above content can be of some help to you, you can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.