示例:
|===========|========|
| Date | Output |
|===========|========|
| 1/14/2018 | day: 1 |
| 1/15/2018 | day: 2 |
| 1/16/2018 | day: 3 |
|===========|========|
3天过后,再次重置为1。
|===========|========|
| Date | Output |
|===========|========|
| 1/17/2018 | day: 1 |
| 1/18/2018 | day: 2 |
| 1/19/2018 | day: 3 |
|===========|========|
应该每3天重置一次。)
我该怎么做?
答案 0 :(得分:1)
您可以在代码中将'baseDate'设置为'1/13/2018',以便将其与今天的日期进行比较。
然后你只需要获得介于两者之间的日子,并获得其“模块3”值:
Dim baseDateString = "14/01/2018"
Dim baseDate As Date = Date.ParseExact(baseDateString, "dd/MM/yyyy",
System.Globalization.DateTimeFormatInfo.InvariantInfo)
Dim datetimeBetween = DateTime.Today.Subtract(baseDate)
Dim daysBetween = datetimeBetween.Days
Dim dayNumber = daysBetween Mod 3 +1
Console.WriteLine("day: " & dayNumber)