Tany Posted February 18, 2010 Posted February 18, 2010 Hi, I am struggling how to convert the VBA n=now() h=h(n) h being y or m or d or h or n or s ... $n = _now() $h = ???($n) must be simple, but I cannot nail it. Thks T
Juvigy Posted February 18, 2010 Posted February 18, 2010 There are many Date and Time functions in already built in AutoIt. Like: _Date_Time_GetSystemTime _Now _NowCalc What exactly do you need to do?
weaponx Posted February 18, 2010 Posted February 18, 2010 Read the help file... @MON @MDAY @YEAR @HOUR @MIN @SEC
Tany Posted February 18, 2010 Author Posted February 18, 2010 There are many Date and Time functions in already built in AutoIt.Like:_Date_Time_GetSystemTime_Now_NowCalcWhat exactly do you need to do?Hi. I have seen all these available functions, but none is getting the y, m, d, h, n(minutes), s out of a date declared variable.At least not so far as i could identify.cheers,T
Tany Posted February 18, 2010 Author Posted February 18, 2010 Hi. I have seen all these available functions, but none is getting the y, m, d, h, n(minutes), s out of a date declared variable.At least not so far as i could identify.cheers,Thm... I see there was a slip of the finger in the example :In VBA it says :n=now()h=hour(n) h being y or m or d or h or n or sin AutoIt this must be :$n = _now()$h = ???($n)
Juvigy Posted February 18, 2010 Posted February 18, 2010 Did you check the weaponx post ? Like for example $seconds=@SEC
weaponx Posted February 18, 2010 Posted February 18, 2010 Roll your own function dude, it's not difficult. expandcollapse popup$timestamp = _NOW() ConsoleWrite($timestamp & @CRLF) ConsoleWrite("Year: " & _Year($timestamp) & @CRLF) ConsoleWrite("Month: " & _Month($timestamp) & @CRLF) ConsoleWrite("Day: " & _Day($timestamp) & @CRLF) ConsoleWrite("Hour: " & _Hour($timestamp) & @CRLF) ConsoleWrite("Minute: " & _Minute($timestamp) & @CRLF) ConsoleWrite("Second: " & _Second($timestamp) & @CRLF) Func _Now() Return StringFormat('%i-%02i-%02i %02i:%02i:%02i',@YEAR, @MON,@MDAY,@HOUR,@MIN,@SEC) EndFunc Func _Year($ts) Return StringMid($ts,1,4) EndFunc Func _Month($ts) Return StringMid($ts,6,2) EndFunc Func _Day($ts) Return StringMid($ts,9,2) EndFunc Func _Hour($ts) Return StringMid($ts,12,2) EndFunc Func _Minute($ts) Return StringMid($ts,15,2) EndFunc Func _Second($ts) Return StringMid($ts,18,2) EndFunc
Tany Posted February 18, 2010 Author Posted February 18, 2010 Did you check the weaponx post ? Like for example $seconds=@SEC Yes, I did. But I am looking to get the seconds/minutes/... out of a calculated variable which is including YMDHMS. The @-functions are an equivalent of the date or time function in VBA, but then limited to the component. You could say that VBA seconds(now()) is equal to AutoIt @SEC. I am looking to get the components out of the calculated variable. Thks T
Tany Posted February 19, 2010 Author Posted February 19, 2010 Yes, I did. But I am looking to get the seconds/minutes/... out of a calculated variable which is including YMDHMS. The @-functions are an equivalent of the date or time function in VBA, but then limited to the component.You could say that VBA seconds(now()) is equal to AutoIt @SEC.I am looking to get the components out of the calculated variable.ThksTSorry. I missed WeaponX. And OK this is a solution. Only... I did not reached the mental state to imagin one has to program his own SquareRoot. These are standard functions in VBA... so I was searching for them, not for "roll your own function".Thank you.T
Tany Posted February 19, 2010 Author Posted February 19, 2010 Roll your own function dude, it's not difficult. Thks MVP. Is indeed not difficult, but I did not reached the mental state to imagine one has to code his own SQUAREROOT. Is standard functionality in VBA. Looking for blood ? Like that. Me(a)t you in Wado Ruy dojo next week. Cheers, T
Moderators Melba23 Posted February 19, 2010 Moderators Posted February 19, 2010 Tany,but I did not reached the mental state to imagine one has to code his own SQUAREROOTYou do not have to - AutoIt can do that for you as you can see here:ConsoleWrite(17^.5 & @CRLF)Remember the very different roots of VBA and AutoIt. AutoIt is growing into a much more complete language than it used to be, but no-one pretends it is there yet. However, it gets closer and closer with every release. Just be pleased that you have a choice of language depending on what you want to do! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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