bartekd Posted May 12, 2009 Posted May 12, 2009 I am using ChrisL's _sql.au3 function. I have one issue with the Array and listView. When I run a particular query, it always removes all the spaces, colons, and dashes. Is there a way that it could be formatted better?Just so you know what I am talking about, here is an example of the same query I ran using Autoit and Query Analyzer.Results in Array[0]|1st Dial[1]|20090415153030Results in Query Analyzer1st Dial ------------------------------------------------------ 2009-04-15 15:30:30.000 Thanks in Advance
weaponx Posted May 12, 2009 Posted May 12, 2009 What is Query Analyzer? It's most likely formatting the dates for you. AutoIt is likely just leaving them in the SQL internal format.
bartekd Posted May 12, 2009 Author Posted May 12, 2009 Its part of the SQL Server 2000 install. Is there a way to format this field in an array like the above?
weaponx Posted May 12, 2009 Posted May 12, 2009 ;Convert YYYYMMDDHHMMSS to YYYY-MM-DD HH:MM:SS $original = "20090415153030" $new = StringRegExpReplace($original, "\A(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(?:.*)","$1-$2-$3 $4:$5:$6") ConsoleWrite($new)
Zedna Posted May 12, 2009 Posted May 12, 2009 version without RegExp: $in = '20090415153030' $out = DateFormat($in) MsgBox(0,'Test',$in & ' --> ' & $out) ; yyyymmddhhmmss --> yyyy-mm-dd hh:mm:ss.sss Func DateFormat($date) If $date = '' Then Return '' Return StringLeft($date,4) & '-' & StringMid($date,5,2) & '-' & StringMid($date,7,2) & ' ' & _ StringMid($date,9,2) & ':' & StringMid($date,11,2) & ':' & StringMid($date,13,2) & '.000' EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search
Moderators SmOke_N Posted May 12, 2009 Moderators Posted May 12, 2009 version without RegExp:Something like that exists? ... Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Zedna Posted May 12, 2009 Posted May 12, 2009 Something like that exists? ... I'm not skilled in RegExp so I can't write such wonderfull RegExp things :-( Resources UDF ResourcesEx UDF AutoIt Forum Search
Valuater Posted May 12, 2009 Posted May 12, 2009 Something like that exists? ... I'm not skilled in RegExp so I can't write such wonderfull RegExp things :-(Me either!! 8)
bartekd Posted May 12, 2009 Author Posted May 12, 2009 ;Convert YYYYMMDDHHMMSS to YYYY-MM-DD HH:MM:SS $original = "20090415153030" $new = StringRegExpReplace($original, "\A(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(?:.*)","$1-$2-$3 $4:$5:$6") ConsoleWrite($new) Thanks allot, this works beautifully.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now