USA dates to UK?

General questions about using TextPad

Moderators: AmigoJack, helios, bbadmin, Bob Hansen, MudGuard

Post Reply
terrypin
Posts: 172
Joined: Wed Jul 11, 2007 7:50 am

USA dates to UK?

Post by terrypin »

I'm struggling to convert USA dates like these:

9/26/20
10/9/21
12/21/22

to these UK equivalents:

26/9/20
9/10/21
21/12/22

Even better would be padded results like this:

26/09/20
09/10/21
21/12/22

Is it possible in a single run please?
User avatar
AmigoJack
Posts: 482
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Re: USA dates to UK?

Post by AmigoJack »

You could have searched the forums and would have found Formatting the system date in a macro:
ineuw wrote: Sat Dec 03, 2022 8:05 am12/3/2022
...
Is it possible to convert the date display to 2022-12-03 format?
That's halfway what you want: a date in the US format and adding leading zeroes (minus the century in the year).
ben_josephs wrote: Sun Dec 04, 2022 11:07 pm Search | Replace... (<F8>):
Find what: \b(\d)?(\d)/(\d)?(\d)/(\d{4})\b
Replace with: $5-(?1$1:0)$2-(?3$3:0)$4

[X] Regular expression
While the output is not what you want, over all the years you surely learnt at least basics of regex. So you just have to adapt to it and want to actually search for a 2 digit year only:

Code: Select all

\b(\d)?(\d)/(\d)?(\d)/(\d{2})\b
and replace it in a just different order:

Code: Select all

(?3$3:0)$4/(?1$1:0)$2/$5
Successfully tested with 8.4.2.
User avatar
ineuw
Posts: 191
Joined: Sun Mar 18, 2007 3:23 pm

Re: USA dates to UK?

Post by ineuw »

Forgive me for this late reply. I appreciate your efforts and much thanks.
TextPad 8.16.0 64bit in English and TextPad 9.1.0 64bit in French, on two separate Windows installations
Post Reply