User Profile
kamleshyadav95
Copper Contributor
Joined 6 months ago
User Widgets
Recent Discussions
date format getting changed from yyyy-mm-dd hh:mm:ss:fff to dd-mm-yyyy hh:mm
Hi All, I am trying to export data from sql server database to csv. data is getting export perfectly in csv file but date format is gettingfrom "yyyy-mm-dd hh:mm:ss:fff" to "dd-mm-yyyy hh:mm". please help to correct it Appreciate quick response. # Define database connection details $server = "YourServerName" $database = "YourDatabaseName" $username = "YourUsername" # Retrieve and decrypt the password $encryptedPassword = Get-Content "C:\path\to\encryptedPassword.txt" | ConvertTo-SecureString $credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $encryptedPassword # SQL query $query = " SELECT * FROM YourTable " $data = Invoke-Sqlcmd -ServerInstance $server -Database $database -Credential $credentials -Query $query $data | Export-Csv -Path "C:\path\to\your\output.csv" -NoTypeInformation -Encoding UTF8 Write-Host "Data exported successfully to C:\path\to\your\output.csv"813Views0likes6Comments
Groups
Recent Blog Articles
No content to show