I am using DateTime.Today
.
Now I'm not sure if the date is from the beginning of the day or the end of the day.
This is what DateTime.Today
returns : {11-3-2014 0:00:00}
The DateTime. Now property returns the current date and time, for example 2011-07-01 10:09.45310 . The DateTime. Today property returns the current date with the time compnents set to zero, for example 2011-07-01 00:00.00000 .
The Now property returns a DateTime value that represents the current date and time on the local computer.
The DateTime value type represents dates and times with values ranging from 00:00:00 (midnight), January 1, 0001 Anno Domini (Common Era) through 11:59:59 P.M., December 31, 9999 A.D. (C.E.) in the Gregorian calendar. Time values are measured in 100-nanosecond units called ticks.
We can use the EOMONTH formula to find the first day of the month as well. EOMONTH returns the last day of a month from a date. Here, we use the EOMONTH function to go to the last day of the previous month. Then, we add 1 to get the first day of the current month.
MSDN states the following: "An object that is set to today's date, with the time component set to 00:00:00."
This means that a DateTime object is created with today's date at the absolute start of the day hence 00:00:00.
You can check if it is the start of the day by using the AddHour() method of the DateTime class.
DateTime d = DateTime.Today;
//AddHours, AddMinutes or AddSeconds
d = d.AddHours(1);
if (d.Date != DateTime.Today.Date)
{
//Not the same day
}
If d.date should be different the date was initialised at a different time (eg. 23:00:01).
http://msdn.microsoft.com/en-us/library/system.datetime.today(v=vs.110).aspx
Thats the beginning of the day, the end of the day would be:
{11-3-2014 23:59:59}
And remember, the only stupid question is the one you don't ask :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With