help with formatting today's date

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
shevach
Posts: 3
Joined: 24 Mar 2023, 06:49

help with formatting today's date

Post by shevach » 24 Mar 2023, 06:56

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

User avatar
mikeyww
Posts: 26596
Joined: 09 Sep 2014, 18:38

Re: help with formatting today's date

Post by mikeyww » 24 Mar 2023, 07:31

Welcome to this AutoHotkey forum!

See Date and time.

How did you find the UseUTC parameter?

shevach
Posts: 3
Joined: 24 Mar 2023, 06:49

Re: help with formatting today's date

Post by shevach » 24 Mar 2023, 08:30

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.

gregster
Posts: 8916
Joined: 30 Sep 2013, 06:48

Re: help with formatting today's date

Post by gregster » 24 Mar 2023, 08:55

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.

garry
Posts: 3740
Joined: 22 Dec 2013, 12:50

Re: help with formatting today's date

Post by garry » 24 Mar 2023, 11:30

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

ShatterCoder
Posts: 69
Joined: 06 Oct 2016, 15:57

Re: help with formatting today's date

Post by ShatterCoder » 24 Mar 2023, 14:56

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

shevach
Posts: 3
Joined: 24 Mar 2023, 06:49

Re: help with formatting today's date

Post by shevach » 25 Mar 2023, 15:17

Thank you very much. It worked perfectly

Post Reply

Return to “Ask for Help (v1)”