1

I have a Stored Procedure that takes Start Date and End Dates. So the Start Date must start from 1/1/2018. I want to make the Start Date as Dynamic- meaning when we are in 2019, the start Date will pick up 1/1/2019 and End Date is always Today's date. I appreciate for any help.

StartDate: 1/1/2018
EndDate: TodaysDate

Thanks

John
  • 13
  • 7
  • 2
    Which dbms are you using? Show us your current code attempt. – jarlh Apr 17 '18 at 14:10
  • 1
    You need to add the DBMS you're using : SQL Server, Oracle, MySQL etc... – CodeNotFound Apr 17 '18 at 14:11
  • Possible duplicate of [Getting the current date in SQL Server?](https://stackoverflow.com/questions/19197471/getting-the-current-date-in-sql-server) – mjwills Apr 17 '18 at 14:12
  • 1
    Which [DBMS product](https://en.wikipedia.org/wiki/DBMS) are you using? "SQL" is just a query language, not the name of a specific database product. Please add a tag for the database product you are using `postgresql`, `oracle`, `sql-server`, `db2`, ... –  Apr 17 '18 at 14:22

1 Answers1

1

you can get it in sql itself like this

SELECT
   DATEADD(yy, DATEDIFF(yy, 0, GETDATE()), 0) AS StartOfYear,
   GETDATE() AS Today
Pranay Rana
  • 175,020
  • 35
  • 237
  • 263