zoukankan      html  css  js  c++  java
  • 获取季度时间

    string firstDayOfThisQuarter = DateTime.Now.AddMonths(0-(DateTime.Now.Month - 1)%3).ToString("yyyy-MM-01");
    Console.WriteLine("本季度的第一天为:{0}",firstDayOfThisQuarter);
    
    string lastDayOfThisQuarter = DateTime.Parse(DateTime.Now.AddMonths(3 - ((DateTime.Now.Month - 1)%3)).ToString("yyyy-MM-01")).AddDays(-1).ToShortDateString();
    string lastDayOfThisQuarter2 = DateTime.Parse(DateTime.Now.AddMonths(3 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01")).AddDays(-1).ToString("yyyy-MM-dd");
    Console.WriteLine("本季度的最后一天为:{0}", lastDayOfThisQuarter);
    Console.WriteLine("本季度的最后一天为:{0}", lastDayOfThisQuarter2);
    
    string firstDayOfNextQuarter = DateTime.Now.AddMonths(3 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01");
    string lastDayOfNextQuarter = DateTime.Parse(DateTime.Now.AddMonths(6 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01")).AddDays(-1).ToShortDateString();
    Console.WriteLine("下季度的第一天为:{0}", firstDayOfNextQuarter);
    Console.WriteLine("下季度的最后一天为:{0}", lastDayOfNextQuarter);
    
    string firstDayOfLastQuarter = DateTime.Now.AddMonths(-3 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01");
    string lastDayOfLastQuarter = DateTime.Parse(DateTime.Now.AddMonths(0 - ((DateTime.Now.Month - 1) % 3)).ToString("yyyy-MM-01")).AddDays(-1).ToShortDateString();
    Console.WriteLine("上季度的第一天为:{0}", firstDayOfLastQuarter);
    Console.WriteLine("上季度的最后一天为:{0}", lastDayOfLastQuarter);

     运行结果:

  • 相关阅读:
    转载 | python inferface使用
    gasshopper之python电池输出dict结构
    Tensorflow 2.0 搭建神经网络(局部)
    grasshopper之python电池执行逻辑
    springboot中给属性文件内容加密(application.properties,application.yml)
    使用docker安装rabbitmq
    关于宝塔Linux面板
    winsw来设置window自启服务
    docker的使用,Nginx,Tomcat,Portainer可视化
    内网穿透(windows)
  • 原文地址:https://www.cnblogs.com/danshui/p/3159935.html
Copyright © 2011-2022 走看看