I am getting an error in VIEW, what is the solution?

NishimuraChinatsu-9854 756 Reputation points
2023-04-06T08:17:45.7333333+00:00

I am getting an error in VIEW, what is the solution? I would like to set the date of delivery after January 1 of the previous year.

User's image

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,696 questions
{count} votes

Accepted answer
  1. Bhargava-MSFT 29,266 Reputation points Microsoft Employee
    2023-04-07T20:31:44.85+00:00

    Hello NishimuraChinatsu-9854, I don't think we can use INTERVAL here. SELECT FORMAT((DATEADD(year, -1, GETUTCDATE())), 'yyyy/MM/dd') The above query will return the date that was one year ago from the current date in the format yyyy/MM/dd To set the date of delivery after January 1 of the previous year, you can modify the DATEADD() function to subtract one year and add one day to get January 1 of the previous year. SELECT FORMAT((DATEADD(day, 1, DATEADD(year, -1, DATEFROMPARTS(YEAR(GETUTCDATE()), 1, 1)))),'yyyy/MM/dd') This query will return January 1 of the previous year in the format yyyy/MM/dd. You can modify the DATEFROMPARTS() function to get the year of the date you want to set the delivery date for.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful