Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date object vs. DateTime object

Tags:

c#

.net

datetime

I am currently looking at the msdn pages for the date and datetime object. I also have reflector opened up, and it looks like the date and datetime object just reference the Date structure. Why do we have two objects which reference the same structure? what is the differences between them?

like image 799
gh9 Avatar asked Apr 19 '11 14:04

gh9


People also ask

What is difference between datetime and date Python?

Python datetime Classesdatetime – Allows us to manipulate times and dates together (month, day, year, hour, second, microsecond). date – Allows us to manipulate dates independent of time (month, day, year).

What is a datetime object?

date Objects. A date object represents a date (year, month and day) in an idealized calendar, the current Gregorian calendar indefinitely extended in both directions. January 1 of year 1 is called day number 1, January 2 of year 1 is called day number 2, and so on. 2 class datetime. date (year, month, day)

What are datetime objects in Python?

The datetime object is kind of a combination of date and time objects. It can store information from year to microseconds. The datetime module also provides some other object types such as timezone, strftime, and strptime.

How do I convert a date to a datetime object?

Using the datetime() Pass the year, month and day values of the desired date object (as my_date. year, my_date. month, my_date. day) to this constructor to convert a date object to datetime object.


1 Answers

The CLR classes (e.g. DateTime, Int32, etc.) contain the actual implementation. This is what you will see in Reflector.

Due to their heritage, C# and VB define certain aliases for commonly used data types. For example, int in C# is an alias of Int32. In VB, one such alias is Date for DateTime.

Here are lists of these aliases:

  • Built-In Types Table (C# Reference)
  • Data Type Summary (Visual Basic)
like image 185
Heinzi Avatar answered Oct 22 '22 18:10

Heinzi