如何转换"串QUOT;到"没有时区&QUOT时间戳; [英] How to convert "string" to "timestamp without time zone"

查看:129
本文介绍了如何转换"串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)使用<一个href=\"http://www.postgresql.org/docs/current/interactive/datatype-datetime.html#DATATYPE-DATETIME-DATE-TABLE\"相对=nofollow> 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')

这篇关于如何转换&QUOT;串QUOT;到&QUOT;没有时区&QUOT时间戳;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆