Formatting the system date in a macro

General questions about using TextPad

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

Post Reply
User avatar
ineuw
Posts: 191
Joined: Sun Mar 18, 2007 3:23 pm

Formatting the system date in a macro

Post by ineuw »

I use a date, time and filename macro which generates the following: 12/3/2022 - 2:57 AM - P:\doc2.txt

Is it possible to convert the date display to 2022-12-03 format?
TextPad 8.16.0 64bit in English and TextPad 9.1.0 64bit in French, on two separate Windows installations
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

It looks like your dates are in crazy US format. Try:

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
You can put this in a macro:
Replace = "\\b(\\d)?(\\d)/(\\d)?(\\d)/(\\d{4})\\b", "$5-(?1$1:0)$2-(?3$3:0)$4", RegExp
DoReplaceAll
Do you not want the time put into 24-hour format?
User avatar
ineuw
Posts: 191
Joined: Sun Mar 18, 2007 3:23 pm

Post by ineuw »

ben_josephs wrote:It looks like your dates are in crazy US format. Try:

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
You can put this in a macro:
Replace = "\\b(\\d)?(\\d)/(\\d)?(\\d)/(\\d{4})\\b", "$5-(?1$1:0)$2-(?3$3:0)$4", RegExp
DoReplaceAll
Do you not want the time put into 24-hour format?
Much thanks for taking the time to help. It's in a new Windows 10 22H2 install whichstill needs a lot of configuration adjustments. The time format is OK.
TextPad 8.16.0 64bit in English and TextPad 9.1.0 64bit in French, on two separate Windows installations
Post Reply