Friday

c# datetime beginning of day

This extension adds EndOfDay StartOfDay methods to DateTime so it's possible to call
DateFrom.Value.StartOfDay() or dateTo.Value.EndOfDay()

 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AwesomeExtensions
{

public static class Extension
{
public static DateTime EndOfDay(this DateTime date)
{
return new DateTime(date.Year, date.Month, date.Day, 23, 59, 59, 999);
}

public static DateTime StartOfDay(this DateTime date)
{
return new DateTime(date.Year, date.Month, date.Day, 0, 0, 0, 0);
}
}
}


No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...