Skip to content

Instantly share code, notes, and snippets.

View r1d3rzz's full-sized avatar
💻
Working from home

MyintThwayKhine r1d3rzz

💻
Working from home
View GitHub Profile
// Assuming employee.PermanentEndDate is DateTime? (nullable DateTime)
if (employee.PermanentEndDate.HasValue)
{
var empPermanentEndDate = employee.PermanentEndDate.Value.Date; // Use .Date to ignore the time part
var today = DateTime.Today;
var previousDay = DateTime.Today.AddDays(-1);
if (empPermanentEndDate == previousDay && previousDay == today)
{
// Do something if empPermanentEndDate is the same as yesterday and today
BULK INSERT [dbo].[Designations]
FROM 'C:\Users\User\Desktop\Designation.csv'
WITH (
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
FIRSTROW = 2
);
@r1d3rzz
r1d3rzz / Get PreviousStartDateAndEndDate.sql
Created July 3, 2024 07:44
Get Previous StartDate And EndDate
DECLARE @CurrentDate DATE = GETDATE();
DECLARE @FirstDayOfPreviousMonth DATE;
DECLARE @LastDayOfPreviousMonth DATE;
-- Calculate the first day of the previous month
SET @FirstDayOfPreviousMonth = DATEADD(MONTH, DATEDIFF(MONTH, 0, @CurrentDate) - 1, 0);
-- Calculate the last day of the previous month
SET @LastDayOfPreviousMonth = EOMONTH(DATEADD(MONTH, -1, @CurrentDate));
@r1d3rzz
r1d3rzz / fileTypeFilter.js
Created June 24, 2024 05:34
File Type Filter WIth JS
function checkFileExtension(file, ...allowFileTypes) {
const allowedExtensions = allowFileTypes; // List allowed extensions
const fileExtension = file.name.split('.').pop().toLowerCase();
return allowedExtensions.includes(fileExtension);
}
function checkContentType(file) {
const allowedTypes = ['image/jpeg', 'image/png', 'application/zip', 'application/pdf']; // List allowed MIME types
return allowedTypes.includes(file.type);
}