Page 1 of 1

help with formatting today's date

Posted: 24 Mar 2023, 06:56
by shevach
I am having lots of trouble with writing dates.
I'm trying to get the following result:
"subject:zera after:{last year, but today's month and day of month}, before:{last year,one month after today's month, and today's date of of month} and paste it to clipboard
This is the code I used:

Code: Select all

!d::
FormatTime, today, %m%d, UseUTC
FormatTime, lastYear, %Y%-1, UseUTC
FormatTime, lastMonth, %m%-1, UseUTC
todayYear := SubStr(today, 3, 2)
todayMonth := SubStr(today, 1, 2)
message := "subject:zera after:" lastYear todayMonth todayYear ", before:" lastYear lastMonth todayYear
Clipboard := message
MsgBox, % "The following message has been copied to the clipboard:`n`n" message
return
However this is the result I am getting:
subject:zera after:U50eUTCU50e, before:U50eUTCU50eUTC0e
can someone help me to know what I'm doing wrong
Thank you very very much


[Mod actions: Moved to v1 section since this is v1 code and the main section is for v2. Added [code][/code] tags. Please use them yourself when posting code.]

Re: help with formatting today's date

Posted: 24 Mar 2023, 07:31
by mikeyww
Welcome to this AutoHotkey forum!

See Date and time.

How did you find the UseUTC parameter?

Re: help with formatting today's date

Posted: 24 Mar 2023, 08:30
by shevach
chatgpt did it for me. But it didn't work. So I decided to ask PEOPLE who really know how to code to help me.

Re: help with formatting today's date

Posted: 24 Mar 2023, 08:55
by gregster
shevach wrote:
24 Mar 2023, 08:30
chatgpt did it for me. But it didn't work.
Yep, that's what we see a lot, and that's one of the reasons why we decided to reject AI-generated code. Please respect this forum rule in the future.

Re: help with formatting today's date

Posted: 24 Mar 2023, 11:30
by garry
- 1 car takes 2 hours from Porto to Lisbon. How long does it take 6 cars to travel the same distance?
- 6 cars would take 12 hours to travel the same distance.
... ok , each 2 hours * 6
maybe ChatGPT-4 is better ...

------------------
https://www.makeuseof.com/openai-chatgpt-biggest-probelms/ ;< - chatgpt would correct this last word ... :)
https://www.makeuseof.com/reasons-artificial-intelligence-cant-replace-humans/
-- 6 Big Problems With OpenAI's ChatGPT
------------------
https://www.theatlantic.com/technology/archive/2022/12/chatgpt-openai-artificial-intelligence-writing-ethics/672386/
-- ChatGPT Is Dumber Than You Think - The Atlantic
------------------
https://www.fastcompany.com/90833017/openai-chatgpt-accuracy-gpt-4
-- ChatGPT's inaccuracies stand in the way of its promise
------------------

Re: help with formatting today's date

Posted: 24 Mar 2023, 14:56
by ShatterCoder

Code: Select all

FormatTime, Year,,yyyy
FormatTime, Month,,MM
FormatTime, Day,,dd
LastYear := Year - 1 " " Month " " Day
LastYearM := (Month < 12? Year - 1: Year) " " Format( "{:02}", M := Month < 12 ? Month + 1 : 01) " " Day

clipboard := "subject:zera after: " LastYear ", before: " LastYearM

Re: help with formatting today's date

Posted: 25 Mar 2023, 15:17
by shevach
Thank you very much. It worked perfectly