C 獲取給定日期所在周次

2021-08-14 08:18:02 字數 374 閱讀 6251

c#可以通過system.globalization這個類來簡單獲取給定日期的周次, 也可以用取得12/31所在周次來計算當年總共有多少周.

using system.globalization;

gregoriancalendar gc = new gregoriancalendar();

datetime datetime = datetime.now;

int week = gc.getweekofyear(datetime, calendarweekrule.firstday, dayofweek.sunday);

這個引數用來指定每週的第一天從週日算起. 這樣就與ms sql: datepart(week,getdate()) 取到的周次一致. 

php相差天數,php獲取給定日期相差天數

這篇文章主要介紹了php獲取給定日期相差天數的方法,結合具體例項形式分析了2種日期相差天數的計算方法,涉及php日期字串轉換的相關操作技巧,需要的朋友可以參考下 方法一 function count days a,b a dt getdate a b dt getdate b a new mktim...

php獲取給定日期相差天數的方法分析

本文例項講述了php獲取給定日期相差天數的方法。分享給大家供大家參考,具體如下 方法一 今天與2017年8月26日相差多少天 date1 strtotime date y m d date2 strtotime 2017 8 26 result count days date1,date2 echo...

查詢給定日期的月份

select substr to char add months to date 200901 yyyymm rownum 1 yyyymm 5,2 月 as month from eos dict entry where add months to date 200901 yyyymm rownu...