![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | What next? Hi people The script I've cobbled together from various sources (thanks to all those anonymous helpers!) looks like this: $cnString = "Server=MYSERVER\SERVER;Database=MYDB;Integrated Security='SSPI'" $cn = new-object System.Data.SqlClient.SqlConnection $cnString $dt = new-object "System.Data.DataTable" $cn.Open() $sql = $cn.CreateCommand() $sql.CommandText = "SELECT max(DateAndTime) FROM EventAudits" $rdr = $sql.ExecuteReader() $dt.Load($rdr) $cn.Close() $dt is a System.Data.DataRow type object that I can now display: $dt | Format-Table Column1 ------- 07/05/2008 10:22:53 What I want to do next is get the value into a datetime value so that I can use it in a comparison with another datetime value, but I've up innumerable blind alleys and still can't see how I do it. Please can somebody help?! Thanks Jacques |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: What next? At last! Thanks Shay. Jacques |
My System Specs![]() |
| | #3 (permalink) | ||||||||||||
| Guest | Re: What next? Hi You can access it like so: $dt.Rows[0].Column1 --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com
| ||||||||||||
My System Specs![]() | |||||||||||||