Date Format with Ordinal Indicators?
-
- Posts: 10
- Joined: Feb 22nd, ’21, 08:05
Hi all, I want to format a date as follows: Wednesday, 24th February 2021.
How would I go about including the ordinal indicators (st, nd, rd, th)?
Thanks!
How would I go about including the ordinal indicators (st, nd, rd, th)?
Thanks!
Nice challenge! There is no standard format for this in Windows so you need to use a small script.
Use "Insert Command Code" macro to insert the following code:
https://www.autohotkey.com/boards/viewtopic.php?t=59936
Use "Insert Command Code" macro to insert the following code:
Code: Select all
Send, % A_DDDD ", " Ordinal(A_DD) " " A_MMMM " " A_YYYY
return
Ordinal(D){
Static Special := {1: "st", 2: "nd", 3: "rd", 21: "st", 22: "nd", 23: "rd", 31: "st"}
Return D . ((S := Special[D]) ? S : "th")
}
-
- Posts: 10
- Joined: Feb 22nd, ’21, 08:05
Thanks Tom, I do like to be challenging
I'll give that a shot.
Thank you again.
I'll give that a shot.
Thank you again.
-
- Posts: 10
- Joined: Feb 22nd, ’21, 08:05
Please could you point me in the direction of where I can work out how to combine this ordinal formatting with the dateshift feature? Basically, within the body of a text expansion, I want to show today+7, formatted with that ordinal format you've kindly given to me above.
Try this:
Code: Select all
date:=A_Now
date += 4, days
day:=SubStr(date, 7, 2)
Special := {1: "st", 2: "nd", 03: "rd", 21: "st", 22: "nd", 23: "rd", 31: "st"}
S := Special[day] ? Special[day] : "th"
FormatTime, date, %date%, dddd, d'%S%', MMMM yyyy
send, % date
-
- Posts: 10
- Joined: Feb 22nd, ’21, 08:05
Thanks Tom, that's getting me the following:
---------------------------
FastKeys.exe
---------------------------
Error at line 153.
Line Text: <html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>Debt C...
Error: Invalid `%.
The program will exit.
---------------------------
OK
---------------------------
It's a HTML formatted text expansion, however when I remove the %CODE_TdyPlus7% variable (containing the code you provided above), I get no errors (and of course no value!).
Any ideas?
---------------------------
FastKeys.exe
---------------------------
Error at line 153.
Line Text: <html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>Debt C...
Error: Invalid `%.
The program will exit.
---------------------------
OK
---------------------------
It's a HTML formatted text expansion, however when I remove the %CODE_TdyPlus7% variable (containing the code you provided above), I get no errors (and of course no value!).
Any ideas?
Sorry, Insert command code macro only works in Non formatted text mode.