简体   繁体   English

键入以在C#中存储时间和PostgreSQL中的相应类型

[英]Type to store time in C# and corresponding type in PostgreSQL

I would like to know how to store time in C# and PostgreSQL 我想知道如何在C#PostgreSQL中存储时间

Ex: 例如:

var startTime = 8.00;
var endTime = 9.20;
var total = endTime - startTime ;
toatl is 80min

And then store this value in a database. 然后将此值存储在数据库中。

In C# you can use DateTime and in PostgreSQL you can use the TIMESTAMP type. 在C#中,您可以使用DateTime ,在PostgreSQL中,您可以使用TIMESTAMP类型。

EDIT 编辑

If you only need to store time, and not date, then you can use the TIME type. 如果您只需要存储时间而不是日期,则可以使用TIME类型。 See also http://www.postgresql.org/docs/8.2/static/datatype-datetime.html . 另见http://www.postgresql.org/docs/8.2/static/datatype-datetime.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM