如何转换"串QUOT;到"没有时区&QUOT时间戳;
我是新来PostgreSQL和我使用WCF服务。结果
这里是我的code片断:
I am new to Postgresql and I am using WCF services.
Here is my code snippet:
$.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'
});
下面:
$('[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?
字符串再一个时间戳
的presentation取决于您的区域设置。因此,为避免歧义,导致Postgres的咳嗽了一个例外,你有两个选择:
String representation of a timestamp
depends on your locale settings. Therefore, to avoid ambiguities leading to Postgres coughing up an exception, you have two options:
1)使用 ISO 8601格式 ,它的工作原理相同用的任何的区域或的 DATESTYLE
设置:
1.) Use ISO 8601 format, which works the same with any locale or DateStyle
setting:
'2013-08-20 14:52:49'
您可能仍然需要显式转换字符串,以避免歧义,这取决于使用情况:
You may still have to cast the string explicitly to avoid ambiguities, depending on the use case:
'2013-08-20 14:52:49'::timestamp
2)你要把你的字符串中使用到时间戳的 TO_TIMESTAMP()
具有匹配模板模式:
2.) Cast your string to timestamp using to_timestamp()
with a matching template pattern:
to_timestamp('20/8/2013 14:52:49', 'DD/MM/YYYY hh24:mi:ss')