By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE dbo.fact1
(
IdRecord int,
FechaRegistro datetime,
IdDimFecCorte int,
);
INSERT dbo.fact1(IdRecord,FechaRegistro,IdDimFecCorte)
VALUES (1, '20220425 23:45:00.000', '20220430'),
(2, '20220424 18:07:00.000', '20220430'),
(3, '20220310 19:04:00.000', '20220331'),
(4, '20220322 16:55:00.000', '20220331'),
(5, '20220210 22:06:00.000', '20220331'),
(6, '20220214 02:06:00.000', '20220331'),
(7, '20220130 21:55:00.000', '20220331')
;
7 rows affected
select * from dbo.fact1
IdRecord | FechaRegistro | IdDimFecCorte |
---|---|---|
1 | 2022-04-25 23:45:00.000 | 20220430 |
2 | 2022-04-24 18:07:00.000 | 20220430 |
3 | 2022-03-10 19:04:00.000 | 20220331 |
4 | 2022-03-22 16:55:00.000 | 20220331 |
5 | 2022-02-10 22:06:00.000 | 20220331 |
6 | 2022-02-14 02:06:00.000 | 20220331 |
7 | 2022-01-30 21:55:00.000 | 20220331 |
CREATE TABLE dbo.fact1Desired
(
IdRecord int,
FechaRegistro datetime,
IdDimFecCorte int,
);
INSERT dbo.fact1Desired(IdRecord,FechaRegistro,IdDimFecCorte)
VALUES (1, '20220425 23:45:00.000', '20220430'),
(2, '20220424 18:07:00.000', '20220430'),
(3, '20220310 19:04:00.000', '20220331'),
(4, '20220322 16:55:00.000', '20220331'),
(5, '20220210 22:06:00.000', '20220228'),--
(6, '20220214 02:06:00.000', '20220228'),--
(7, '20220130 21:55:00.000', '20220131')--
;
7 rows affected
select * from dbo.fact1Desired
IdRecord | FechaRegistro | IdDimFecCorte |
---|---|---|
1 | 2022-04-25 23:45:00.000 | 20220430 |
2 | 2022-04-24 18:07:00.000 | 20220430 |
3 | 2022-03-10 19:04:00.000 | 20220331 |
4 | 2022-03-22 16:55:00.000 | 20220331 |
5 | 2022-02-10 22:06:00.000 | 20220228 |
6 | 2022-02-14 02:06:00.000 | 20220228 |
7 | 2022-01-30 21:55:00.000 | 20220131 |