Why am I getting this error executing DateDiff function?

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
slishnevsky
Posts: 34
Joined: 07 Mar 2024, 06:50

Why am I getting this error executing DateDiff function?

29 Mar 2024, 19:59

Why am I getting this error executing DateDiff function?

image.png
image.png (39.72 KiB) Viewed 56 times
gregster
Posts: 9095
Joined: 30 Sep 2013, 06:48

Re: Why am I getting this error executing DateDiff function?

29 Mar 2024, 20:16

Datediff needs date-time stamps in the YYYYMMDDHH24MISS format. Your picture of the error message shows what you got instead.
https://www.autohotkey.com/docs/v2/lib/FormatTime.htm#Parameters wrote:Format

Type: String

If blank or omitted, it defaults to the time followed by the long date, both of which will be formatted according to the current user's locale. For example: 4:55 PM Saturday, November 27, 2004
[...]

Why not use

Code: Select all

time1 := A_Now
Sleep(2000)
time2 := A_Now
MsgBox DateDiff(time1, time2, 'Seconds')
gregster
Posts: 9095
Joined: 30 Sep 2013, 06:48

Re: Why am I getting this error executing DateDiff function?

29 Mar 2024, 20:18

btw, it is recommended to post code in a codebox instead of a picture. That way, people can easily test your code.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Google [Bot], MagEpub and 22 guests