I am new to Postgresql and I am using WCF services.
Here is my code snippet:
我是Postgresql的新手,我正在使用WCF服务。下面是我的代码片段:
$.ajax({
url: '../Services/AuctionEntryServices.svc/InsertAuctionDetails',
data: JSON.stringify({ "objAuctionEntryEntity": {
"AuctionNO": '',
"AuctionDate": $('[Id$="lblAuctionDateVal"]').text(),
"TraderID": $('[Id$="ddlTraderName"] option:selected').val(),
"Grade": $('[Id$="ddlGrade"] option:selected').val(),
"Varity": $('[Id$="ddlVarity"] option:selected').val(),
"QuntityInAuction": $('#txtQuantityForAuction').val(),
"AuctionRate": $('#txtAuctionRate').val(),
"BrokerID": a[0],
"IsSold": $('#chlIsSold').is(':checked'),
"CreatedBy": $.parseJSON(GetCookie('Admin_User_In_Mandi')).UserID,
"UpdatedBy": $.parseJSON(GetCookie('Admin_User_In_Mandi')).UserID,
"CreationDate": GetCurrentDate().toMSJSON(),
"IsActive": true,
"AuctionTransaction": arrAuctionTransaction,
"MandiID": $.parseJSON(GetCookie('Admin_User_In_Mandi')).MandiID,
"FarmerID": _ownerid,
"AuctionNO": _auctionno,
"AmmanatPattiID": _ammantpattiid,
"ToTraderID": b[0],
"ToTraderName": $('#txtOtherBuyerNameEN').val(),
"ToTraderName_HI": $('#txtOtherBuyerNameHI').val()
}
}),
type: 'POST',
contentType: 'application/json',
dataType: 'json'
});
Here:
在这里:
$('[Id$="lblAuctionDateVal"]').text() = "20/8/2013 14:52:49"
And my data type for this field is timestamp without time zone
.
How to convert this string to timestamp without time zone
data type?
这个字段的数据类型是没有时区的时间戳。如何将该字符串转换为没有时区数据类型的时间戳?
2 个解决方案
#1
34
String representation of a timestamp
(= timestamp without time zone
) depends on your locale settings. Therefore, to avoid ambiguities leading to data erros or Postgres coughing up an exception, you have two options:
时间戳的字符串表示形式(=没有时区的时间戳)取决于您的语言环境设置。因此,为了避免导致数据erros或Postgres出现异常的歧义,您有两个选择:
1.) Use ISO 8601 format, which works the same with any locale or DateStyle
setting:
1)。使用ISO 8601格式,适用于任何地区或日期设置:
'2013-08-20 14:52:49'
You may still have to cast the string explicitly where the data type is no known a priori, depending on the use case:
您可能仍然需要在数据类型未知的情况下显式地转换字符串,具体取决于用例:
'2013-08-20 14:52:49'::timestamp
2.) Convert your string to timestamp
using to_timestamp()
with a matching template pattern:
2)。使用to_timestamp()将字符串转换为时间戳,并使用匹配的模板模式:
to_timestamp('20/8/2013 14:52:49', 'DD/MM/YYYY hh24:mi:ss')
#2
13
To convert a string into a timestamp without timezone, for Postgresql, I use the above
要将字符串转换为没有时区的时间戳,对于Postgresql,我使用上面的代码
SELECT to_timestamp('23-11-1986 09:30:00', 'DD-MM-YYYY hh24:mi:ss')::timestamp without time zone;
#1
34
String representation of a timestamp
(= timestamp without time zone
) depends on your locale settings. Therefore, to avoid ambiguities leading to data erros or Postgres coughing up an exception, you have two options:
时间戳的字符串表示形式(=没有时区的时间戳)取决于您的语言环境设置。因此,为了避免导致数据erros或Postgres出现异常的歧义,您有两个选择:
1.) Use ISO 8601 format, which works the same with any locale or DateStyle
setting:
1)。使用ISO 8601格式,适用于任何地区或日期设置:
'2013-08-20 14:52:49'
You may still have to cast the string explicitly where the data type is no known a priori, depending on the use case:
您可能仍然需要在数据类型未知的情况下显式地转换字符串,具体取决于用例:
'2013-08-20 14:52:49'::timestamp
2.) Convert your string to timestamp
using to_timestamp()
with a matching template pattern:
2)。使用to_timestamp()将字符串转换为时间戳,并使用匹配的模板模式:
to_timestamp('20/8/2013 14:52:49', 'DD/MM/YYYY hh24:mi:ss')
#2
13
To convert a string into a timestamp without timezone, for Postgresql, I use the above
要将字符串转换为没有时区的时间戳,对于Postgresql,我使用上面的代码
SELECT to_timestamp('23-11-1986 09:30:00', 'DD-MM-YYYY hh24:mi:ss')::timestamp without time zone;