Translate

Home > July 2020

July 2020

ASP.NET C# File Download

Saturday, July 18, 2020 Category : 0

HttpContext.Current.Response.ContentType = "application/x-download";
                HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=RosterFormat.xlsx");
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.WriteFile(path);
                HttpContext.Current.Response.End();

SQL Date Loop For Each Month

Thursday, July 2, 2020 Category : 0


 DECLARE @FromDate DATETIME
 SET @FromDate='01/01/2020'

 DECLARE @ToDate DATETIME
 SET @ToDate= CONVERT(DATETIME, CAST(  DATEPART(MONTH,GETDATE()) AS NVARCHAR(50) ) + '/01/' + CAST( DATEPART(YEAR,GETDATE()) AS NVARCHAR(50)) ,101 )

 DECLARE @TableName NVARCHAR(50)

 WHILE (@FromDate <= @ToDate)
 BEGIN

     SET @TableName = 'Sales'+ CAST( DATEPART(YEAR,@FromDate) AS NVARCHAR(50)) + RIGHT('00'+ISNULL( CAST( DATEPART(MONTH,@FromDate) AS NVARCHAR(50)) ,''),2)
     PRINT @TableName

     SET @FromDate = DATEADD(MONTH,1,@FromDate)
 END

Powered by Blogger.