I am querying data with a date I insert at the end of the query at the end of EXEC command but I want to use the GETDATE function to query yesterday if possible since I plan on running these queries on a schedule and not manually. I don't want to have to go and edit the date every day.
USE [EXP]
GO
DECLARE @DateFrom datetime;
SET @DateFrom = DATEADD(day, -1, cast(getdate() as date));
/****** Object: Table [dbo].[Trans] Script Date: 6/11/2021 9:25:00 AM ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Trans]') AND type in (N'U'))
DROP TABLE [dbo].[Trans]
GO
/****** Object: Table [dbo].[Trans] Script Date: 6/11/2021 9:25:00 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Trans](
[Account] [varchar](8) NULL,
[Amount] [money] NOT NULL,
[typename] [varchar](20) NULL,
[DateEffective] [datetime] NULL,
[TranDesc] [varchar](200) NULL,
[DRAmount] [money] NULL,
[CRAmount] [money] NULL,
[CUUser] [varchar](50) NULL,
[Deleted] [bit] NULL
) ON [PRIMARY]
GO
--set identity_insert Trans on
insert into Trans
([Account]
,[Amount]
,[typename]
,[DateEffective]
,[TranDesc]
,[DRAmount]
,[CRAmount]
,[CUUser]
,[Deleted])
EXEC [FER_DP].[DP].[dbo].[Excel_Trans] @DateFrom;