I am getting back a date time from MailChimp that has the format yyyy-MM-ddTHH:mm:ss+00:00
. An example is 2016-11-14T17:31:19+00:00
.
I am not sure how I should reformat this to fit into the SQL Server Datetime
format. I am coding in 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
}