How would i save the date time, with no time or preferably with a time stamp of 12:00, no matter what the time is at that moment?
I dont want to use .ToString("dd/MM/yyyy");
, because it will open up a whole lot of new possible errors.
Use Date Data type to create a Date column/variable without any time information. The time defaults to 00:00:00 and sql server will not store it in the Database. Hence it is very efficient way to store date, when there is no need to store time.
For example, the "d" standard format string indicates that a date and time value is to be displayed using a short date pattern. For the invariant culture, this pattern is "MM/dd/yyyy". For the fr-FR culture, it is "dd/MM/yyyy". For the ja-JP culture, it is "yyyy/MM/dd".
DateTime
struct has a Date
property that should serve your needs:
DateTime dateOnly = dateTime.Date;
Of course, it'll still inevitably contain a time part but you should be able to ignore it.
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