From 7f98035c40465f1d8df3e18d84588817e4306595 Mon Sep 17 00:00:00 2001 From: Chrissy LeMaire Date: Thu, 16 May 2024 17:06:22 +0200 Subject: [PATCH] ConvertTo-DbaDataTable - Fix DbaDateTime issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As proposed by GPT 4o 🤞 --- public/ConvertTo-DbaDataTable.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/public/ConvertTo-DbaDataTable.ps1 b/public/ConvertTo-DbaDataTable.ps1 index bf2adf3ff5..c0bbecd772 100644 --- a/public/ConvertTo-DbaDataTable.ps1 +++ b/public/ConvertTo-DbaDataTable.ps1 @@ -166,6 +166,11 @@ function ConvertTo-DbaDataTable { } } $specialType = 'Size' + } elseif ($type -eq 'Dataplat.Dbatools.Utility.DbaDateTime') { + $special = $true + $value = [System.DateTime]$value.DateTime + $type = 'System.DateTime' + $specialType = 'DateTime' } elseif (-not ($type -in $types)) { # All types which are not found in the array will be converted into strings. # In this way we don't ignore it completely and it will be clear in the end why it looks as it does. @@ -217,6 +222,9 @@ function ConvertTo-DbaDataTable { $Value.$TimeSpanType } } + 'DateTime' { + return [System.DateTime]$Value.DateTime + } } }