• C#的DateTime得到特定日期


    //指定时间
    DateTime dt = new DateTime(2016, 6, 1);

    //当前时间
    DateTime dt = DateTime.Now;

    //本周周一
    DateTime startWeek = dt.AddDays(1-Convert.ToInt32(dt.DayOfWeek.ToString("d")));

    //本周周日
     DateTime endWeek = startWeek.AddDays(6);

    //本月月初
    DateTime startMonth = dt.AddDays(1 - dt.Day);

    //本月月末
    DateTime endMonth = dt.AddDays(1 - dt.Day).AddMonths(1).AddDays(-1);

    //本月月末
    DateTime endMonth = startMonth.AddDays((dt.AddMonths(1) - dt).Days - 1);

    //本季度初
    DateTime startQuarter = dt.AddMonths(0 - (dt.Month - 1) % 3).AddDays(1 - dt.Day);

    //本季度末
    DateTime endQuarter = startQuarter.AddMonths(3).AddDays(-1);

    //本年年初
    DateTime startYear = new DateTime(dt.Year, 1, 1);

    //本年年末
    DateTime endYear = new DateTime(dt.Year, 12, 31);

  • 相关阅读:
    redis搭建集群
    redis搭建主从
    redis与python交互
    redis数据操作篇
    redis配置篇
    node 淘宝镜像
    java 深copy
    springmvc配置访问静态文件
    centos 启动 oracle
    List 分隔多次执行 且在同一个事物当中
  • 原文地址:https://www.cnblogs.com/haxianhe/p/9271191.html
Copyright © 2020-2023  润新知