How to display short date from DateTime field in label?

后端 未结 4 1788
走了就别回头了
走了就别回头了 2021-01-14 09:13

I have a DateTime field in my SQL Server DB, and I would like to display just the date in short date form on a label in a WinForm (C#). I still get 06/01/2013 12:00:00, thou

4条回答
  •  天命终不由人
    2021-01-14 10:00

    You can use Data annotation in model (or in ViewModel) class like follows:

    [DataType(DataType.Date)]
    public DateTime DateOfExpiration { get; set; }
    

提交回复
热议问题