0
我从MailChimp获取格式为yyyy-MM-ddTHH:mm:ss+00:00
的日期时间。一个例子是2016-11-14T17:31:19+00:00
。将格式化为yyyy-MM-ddTHH:mm:ss + 00:00转换为SQL Server日期时间格式
我不知道我应该如何重新格式化以符合SQL Server Datetime
格式。我在PowerShell中编码。
#HTTP Get returns datetime from mailchimp in format yyyy-MM-ddTHH:mm:ss+00:00
$MailChimpTimeGMT = Invoke-RestMethod -Method Get -Uri "$URL$endpoint" -Headers $auth -ContentType "application/json"
$formattedTime = ((Get-Date).ToUniversalTime()).ToString("yyyy-MM-ddTHH:mm:ss+00:00")
if ($formattedTime -lt $MailChimpTimeGMT) {
#$DBase and $DBSvr declared
#
#Need to convert $MailChimpTimeGMT in match SQL date time format without loss
#
$sqlcmd = "INSERT INTO dbo.MAILCHIMP_LISTSERVE (TIME_STAMP,MODIFY_SOURCE)" +
" VALUES (" + $MailChimpTimeGMT + ", powershell);"
$data = Invoke-Sqlcmd -Query $sqlcmd -Database $DBase -ServerInstance $DBSvr
}
Google cast and convert。您正在寻找的数量是127. –
Btw,[日期不存储与它的显示格式在SQL Server中。](http://stackoverflow.com/a/30033028/3094533) –
谢谢。我不知道如何转换和转换! – user6927085