Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to Convert SMO Date property to a SQL DateTime

$
0
0

Hi,

I am retrieving the SMO Database CreateDate property and trying to insert this into a T-SQL DateTime column.   The following is a sample of Powershell code to retrieve this property:$serverA.Databases[0].CreateDate  The format of the CreateDate returned is "Monday, October 03, 2011 10:31:25 AM" and I would like it to be in this format: "2011-10-03 10:31:25" for inserting into a SQL 2012 table.  Is there a function or method that will retrieve the CreateDate in this format?

Thanks for all your help.

Gary


Gary


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>