Let’s say we want to find the date of the first Friday of the 1st month. GetFirstFridayOfMonth(01.01.2023) =>06.01.2023 (The first Friday after 01.01.2023 is 06.01.2023) public DateTime GetFirstFridayOfMonth(DateTime date) { DateTime fridayDate = new DateTime(date.Year, date.Month, 1); //Let’s assume 1st Friday can start on the 1st of the month while (fridayDate.DayOfWeek != DayOfWeek.Friday) { fridayDate […]
Tag: count
How to get rows count in EntityFramework without loading contents
Query syntax: var count = (from t in context.MyTable where t.Id == @Id select t).Count(); Method syntax: var count = context.MyTable .Where(t => t.Id == @Id) .Count() Both generate the same SQL query.
How To Get All Row Count For All Tables In SQL Server Database
SELECT (SCHEMA_NAME(A.schema_id) + ‘.’ + A.Name) AS TableName , SUM(B.rows) AS RecordCount FROM sys.objects A INNER JOIN sys.partitions B ON A.object_id = B.object_id WHERE A.type = ‘U’ GROUP BY A.schema_id, A.Name ORDER BY RecordCount DESC
Javascript Refresh and CountDown Timer
<script type=”text/javascript”> function checklength(i) { ‘use strict’; if (i < 10) { i = “0” + i; } return i; } var minutes, seconds, count, counter, timer; count = 301; //seconds counter = setInterval(timer, 1000); function timer() { ‘use strict’; count = count – 1; minutes = checklength(Math.floor(count / 60)); seconds = checklength(count – minutes […]
Return number of rows affected by UPDATE statements in SQL
DECLARE @Teams TABLE( Name varchar(100) ) INSERT INTO @Teams VALUES (N’GALATASARAY’) INSERT INTO @Teams VALUES (N’LIVERPOOL’) INSERT INTO @Teams VALUES (N’BARCELONA’) INSERT INTO @Teams VALUES (N’PARIS SAINT GERMAIN’) INSERT INTO @Teams VALUES (N’JUVENTUS’) UPDATE @Teams SET Name = N’PORTO’ WHERE Name = ‘PARIS SAINT GERMAIN’ SELECT @@ROWCOUNT –gives 1
Get the count of Duplicate Records in SQL
First, Let’s have the table and its records: