DateTime
stores a date as a numerical value, not as a string. So asking for a DateTime
type of format 'MM/dd/yyyy' doesn't make much sense. If you are displaying the date in a WPF control, it will default to displaying a string that conforms to the system date format. But that is just a display string that you can manipulate using the format strings alluded to in the links above. Using @Sajeetharan's code will create a DateTime
struct with the correct value internally. How you display it is up to you and your string formatting choices.
The same goes for dates stored in a database column of type 'datetime'. The value is stored numerically. Your query editor will display the value likely in the same format as your system settings. If the date is stored as a string, then again, @Sajeetharan's code is the correct way to convert the database string into a DateTime
struct.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…