Jump to content

Recommended Posts

Posted

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

Posted

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?

Posted

  On 2/18/2010 at 2:13 PM, 'Juvigy said:

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?

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

Posted

  On 2/18/2010 at 3:44 PM, 'Tany said:

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

hm... 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 s

in AutoIt this must be :

$n = _now()

$h = ???($n)

Posted

Roll your own function dude, it's not difficult.

$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
Posted

  On 2/18/2010 at 3:47 PM, 'Juvigy said:

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

Posted

  On 2/18/2010 at 4:00 PM, 'Tany said:

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

Sorry. 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

Posted

  On 2/18/2010 at 3:55 PM, weaponx said:

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
Posted

Tany,

  Quote

but I did not reached the mental state to imagine one has to code his own SQUAREROOT

You 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. :mellow:

Just be pleased that you have a choice of language depending on what you want to do! :(

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...