Page 1 of 1

Formatting Date and Time

Posted: Tue Jun 12, 2012 7:44 am
by ohoover
I need to create a variable with the current date/time in the following format: yyyy/mm/dd_HHMMSS
Is this possible? For the "$TIME$" variable, I did not see military time as an option.

Re: Formatting Date and Time

Posted: Tue Jun 12, 2012 10:32 am
by FrancescoT
Dear User,

you could do it via script using Parse String command in order to have your desired format.

I suggest to you to have a look at the following forum topic.
it does not demonstrate you specific request, but can be used as a very useful starting point.

http://www.installaware.com/forum/viewt ... f=4&t=3167

Regards

Re: Formatting Date and Time

Posted: Fri Jul 06, 2012 12:26 pm
by ohoover
Thanks for the sample. However, the month and day are single digits and I always need them to be double digits ex 2012-07-06 instead of 2012-7-6. Is there anyway to check for the length of the month or day and then append a 0 to the front if the length is just 1?

Re: Formatting Date and Time

Posted: Mon Jul 09, 2012 9:57 am
by FrancescoT
Dear User,

the first possible thing that comes to my mind is to use a call to "lstrlen" WIN API function.
It returns the number of characters in a string.

To call it use "Call DLL function" command as the following example:

Code: Select all

~InstallAware Clipboard Data~
~Call DLL Function~
~{5BAE1FEF-7F2C-46CE-B9AF-D5675673749C}~
~Kernel32.dll,lstrlenA,long,,"pointer to string",MYVARIABLE,$~
~mIDEFunc.dll\mEXEFunc.dll~

Code: Select all

Call DLL Function Kernel32.dll->lstrlenA
Then have a look also at the following topic for an alternative solution using IA script command:
http://www.installaware.com/forum/viewt ... ?f=2&t=609

Hope this helps you.

Regards