How to insert the date in a specified format with a macro?

Help with writing and playing macros

How to insert the date in a specified format with a macro?

Postby AllanB » Thu Mar 12, 2009 9:35 am

Hi,

new to macros. Love UltraEdit.
What I want to do is at the end of this macro I want to put a string of today's data in this format: _2009-03-12-11-03AM.txt

The macro won't compile due to the last line. It appears I cannot interpret the code sample in the manual correctly.
Any healp would be greatly appreciated.

TIA

Allan

InsertLine
"/* ====================================== */"
InsertLine
"/* NAME : "
CopyFilePath
Paste
" */"
InsertLine
"/* PROJECT : xxxx */"
InsertLine
"/* AUTHOR : AllanB */"
InsertLine
"/* LAST MOD : "
TimeDate
" */"
InsertLine
"/* ====================================== */"
InsertLine
InsertLine
InsertLine
[DATE_USER_SYS]'_'yyyy'-'mm'-'dd'-'hh'-'mmtt[DATE_USER_SYS_END]
AllanB
Newbie
 
Posts: 2
Joined: Thu Mar 12, 2009 9:30 am

Re: How to insert the date in a specified format with a macro?

Postby Mofi » Thu Mar 12, 2009 10:04 am

You can't use a template definition in a macro. You have to create a template and call this from within the macro. For example I have 2 templates:

Template 0 is named "Date German" and has the template code [DATE_USER]dd'.'MM'.'yyyy[DATE_USER_END]

Template 1 is named "Date International" and has the template code [DATE_USER]yyyy'-'MM'-'dd[DATE_USER_END]

In a macro which is written for updating dates in HTML files I use the macro commands Template 0 and Template 1.


A second variant is to use the macro command TimeDate to insert date and time as defined in the Windows regional and language settings and reformat it with a regular expression search and replace. I don't like this method because it depends on the date and time format defined in the regional and language settings of Windows. So I don't have control how the inserted date and time looks like. But this variant has the advantage that it does not depend on the currently loaded templates.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4062
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: How to insert the date in a specified format with a macro?

Postby AllanB » Thu Mar 12, 2009 11:21 am

Thanks for you help

Allan
AllanB
Newbie
 
Posts: 2
Joined: Thu Mar 12, 2009 9:30 am


Return to Macros