Reputation: 209
I want to run a report where i want to pass parameters as starttime which is yesterday 12 am(midnight) and enddate as today 12 am (mid night), how to get midnight time in datetime format in c#
Upvotes: 3
Views: 11639
Reputation: 12874
From Date: DateTime.Today.AddDays(-1)
To Date: DateTime.Today
Upvotes: 1
Reputation: 263723
how about you pass the following format? yyyy-MM-dd HH:mm:ss
so if applied in you code:
it should be 2012-05-12 00:00:00
to 2012-05-13 00:00:00
don't forget to include the time.
Upvotes: 1
Reputation: 223267
An object that is set to today's date, with the time component set to 00:00:00.
Console.Write(DateTime.Today);
Output:
5/11/2012 12:00:00 AM
Upvotes: 3
Reputation: 515
The answer is here.Just you have to search properly.Anyways here is the answer ,just use
DateTime.Today for today's date
Upvotes: 2
Reputation: 1786
Current date without any time (at midnight)
DateTime.Today
Yesterday at midnight
DateTime.Today.AddDays(-1)
Upvotes: 10