| |

VerySource

 Forgot password?
 Register
Search
View: 705|Reply: 7

Is there any good way to find the date of the first three days of today?

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-9 00:00:01
| Show all posts |Read mode
Everyone:
    As the question, is there any good way?
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-5-29 15:45:01
| Show all posts
Today: 20170105
Demand: 20170102

Today: 20170101
Demand: 20161229
Reply

Use magic Report

0

Threads

119

Posts

67.00

Credits

Newbie

Rank: 1

Credits
67.00

 China

Post time: 2020-5-29 16:15:01
| Show all posts
AddDays (-1)
AddDays (-2)
DateTime.AddDays ()
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-29 17:45:01
| Show all posts
Data.Today.Date.AddDays (-3)
Basically like this!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-5-29 18:15:01
| Show all posts
DateTime.AddDays (-3)
Reply

Use magic Report

0

Threads

17

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-5-30 06:30:02
| Show all posts
dt.AddDays (-3) .ToString ("yyyyMMdd")
Reply

Use magic Report

0

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-5-30 13:15:01
| Show all posts
String strDt = "20170105";
strDt = System.Text.RegularExpressions.Regex.Replace (strDt, @ "(? <Y> ^\d {4}) (? <M>\d {2}) (? <D>\d {2} $)", "$ {Y}-$ {M}-$ {D}");

DateTime dt1 = DateTime.Parse (strDt);
DateTime dt2 = dt1.AddDays (-3);
The
Console.WriteLine ("result = {0}", dt2.ToString ("yyyyMMdd"));
Console.ReadLine ();
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-5-30 16:45:01
| Show all posts
Thank you all, get it done!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list