Friday, July 28, 2017
Date Dimension Generator
Following SQL query is to create simple date dimension table and then insert values to the given range.
Create table
CREATE TABLE [dbo].[DimDate](
[Date] [date] NOT NULL,
[Day] [varchar](10) NULL,
[Month] [varchar](10) NULL,
[Year] [int] NULL
) ON [PRIMARY]
GO
Script to generate date
DECLARE @startDate date;
DECLARE @endDate date;
SET @startDate = '2017-01-01';
SET @endDate = '2018-12-31';
WHILE(@startDate <= @endDate)
BEGIN
INSERT dbo.DimDate
SELECT
CONVERT(Datetime, @startDate, 120) [Date],
DATENAME(DW,@startDate) [Day],
DATENAME(MM,@startDate) [Month],
DATEPART(YY,@startDate) [Year]
SET @startDate = DATEADD(DD, 1, @startDate )
END
Subscribe to:
Post Comments (Atom)
Date dimension generator is working on the right manner for the creation of the table. You can get the right script to generate the date. The sop psychology is working with this deal which is not bad.
ReplyDeleteIt's the SQL query of the date dimension generator to the table and the values to insert. You can use this script and can learn from it to make more source code for the useful work. With the help of https://www.phdproposal.net/scientific-research-dissertation-writing-process/ you can get the idea about this SQL query.
ReplyDeleteWe appreciate that you got the right information out of this. And yes, contingent on the type of work, statistical analysis is a good skill to have read more
ReplyDeleteThis website always help students in their different dimension. Date dimension generator is working properly for many data base programs so we should appreciate it.
ReplyDelete