Sign in to follow this  
Followers 0
RagsRevenge

Help with date/time format

3 posts in this topic

Hi,

I'm running a SQL query using ODBC. I'm displaying the results of this query in a Listview. A couple of the fields are Date/Time format, formatted as General Date in Access: 06/08/2009 10:34:23 according to my local settings.

Everything is working as expected, except my date/time fields are displaying in AutoIt (Listview and MsgBox) like 20090806103423, even if I include a format() call in my SQL query.

I've looked inside date.au3, and the existing format functions are no good for the format of my date/time.

Is there a built in function to format my date/time from my format, or is it something I just have to do myself? It's no problem to do it myself, but I just don't want to reinvent the wheel due to lack of knowledge,

Thanks,

D

Share this post


Link to post
Share on other sites



If all time is in there format isn't too hard to format time and date:

$DT = "20090806103423"

MsgBox(0,"Format",DTFormat($DT))

Func DTFormat($DT)
    If StringLen($DT) = 14 Then
        $YYYY = StringLeft($DT,4)
        $MM = StringMid($DT,5,2)
        $DD = StringMid($DT,7,2)
        $HH = StringMid($DT,9,2)
        $MN = StringMid($DT,11,2)
        $SS = StringRight($DT,2)
        Return $DD & "/" & $MM & "/" & $YYYY & " " & $HH & ":" & $MN & ":" & $SS
    EndIf
    Return -1
EndFunc

When the words fail... music speaks

Share this post


Link to post
Share on other sites

If all time is in there format isn't too hard to format time and date:

$DT = "20090806103423"

MsgBox(0,"Format",DTFormat($DT))

Func DTFormat($DT)
    If StringLen($DT) = 14 Then
        $YYYY = StringLeft($DT,4)
        $MM = StringMid($DT,5,2)
        $DD = StringMid($DT,7,2)
        $HH = StringMid($DT,9,2)
        $MN = StringMid($DT,11,2)
        $SS = StringRight($DT,2)
        Return $DD & "/" & $MM & "/" & $YYYY & " " & $HH & ":" & $MN & ":" & $SS
    EndIf
    Return -1
EndFunc

Thanks Andreik,

That was beyond the call of duty, as this was what I realised I'd have to do, if a built in function didn't already exist.

Props,

D

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0