Rabu, 12 Oktober 2011
Hari minggu
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER function [dbo].[fget_sunday_of_year](@year int)
RETURNS @tabel TABLE (date datetime)
AS
BEGIN
DECLARE @date datetime, @n int, @i int;
SET @i=1;
SET @date=(SELECT cast(year(cast(@year as varchar(4))) as varchar(4))+'-12-31');
SET @n=(SELECT DATEPART(wk, @date));
SET @date=(SELECT DATEADD(DAY, (7 - DATEDIFF(DAY, '17530101', DATEADD(YEAR, DATEDIFF(YEAR, 0, @date), '19000101')) % 7) % 7, DATEADD(YEAR, DATEDIFF(YEAR, 0, @date), '19000101'))-1 AS date)
INSERT @tabel
SELECT @date
WHILE(@i<@n-1)
BEGIN
SET @date=(SELECT @date+7);
INSERT @tabel
SELECT @date;
SET @i=@i+1;
END
RETURN;
END;
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER function [dbo].[fget_sunday_of_year](@year int)
RETURNS @tabel TABLE (date datetime)
AS
BEGIN
DECLARE @date datetime, @n int, @i int;
SET @i=1;
SET @date=(SELECT cast(year(cast(@year as varchar(4))) as varchar(4))+'-12-31');
SET @n=(SELECT DATEPART(wk, @date));
SET @date=(SELECT DATEADD(DAY, (7 - DATEDIFF(DAY, '17530101', DATEADD(YEAR, DATEDIFF(YEAR, 0, @date), '19000101')) % 7) % 7, DATEADD(YEAR, DATEDIFF(YEAR, 0, @date), '19000101'))-1 AS date)
INSERT @tabel
SELECT @date
WHILE(@i<@n-1)
BEGIN
SET @date=(SELECT @date+7);
INSERT @tabel
SELECT @date;
SET @i=@i+1;
END
RETURN;
END;
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
Langganan:
Posting Komentar (Atom)
Blog Archive
About Me
- Koral Web
- Kami adalah web developer. Beberapa produk yang pernah kami buat antara lain website, aplikasi klinik, aplikasi apotik, aplikasi EDMS (Electronic Database Management System), Energy Consumption Management System, RKBI (Rencana Kunjungan Barang Import) dan lain-lain sesuai dengan request dari client kami. Jika Anda tertarik untuk membuat system atau aplikasi, jangan sungkan-sungkan menghubungi kami.
Bahasa Pemrogramanmu?
Nasihat
Barangsiapa capek lelah dan letihnya bukan karena Allah maka celakalah dia
Diberdayakan oleh Blogger.
Web Sunnah
Blog Archieve
- Info (3)
- Kajian (3)
- My Program (1)
- Orang Terkenal (1)
- scrip (2)
- SQL (23)
- Subquery (9)
- Trik (13)
0 comments:
Posting Komentar