This is my technical area for troubleshooting and learning new programming skills and much more. Here, you will find answers on a wide range of technologies such as AI, Machine Learning, OpenAI, Databricks, ASP.NET, C#, Python, Microsoft Access, MySQL, Amazon Web Services, SQL Server, PL/SQL, JD Edwards, SAS, Salesforce, APIs, MVC, and many others. Please feel free to visit and join the discussion!
Thursday, August 29, 2013
Get Rolling 6 Months in SQL-Server
SELECT x.months, [YYYYMM] = CAST(CONVERT(CHAR(6),Months,112) AS INT)
FROM (VALUES (0),(1),(2),(3),(4),(5),(6)) r (n)
CROSS APPLY (SELECT Months = DATEADD(mm,-n,GETDATE())) x
No comments:
Post a Comment