 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
nico
Joined: 08 May 2001 Posts: 13
|
|
manipulating date format. |
|
I am using the FileDate to get the date of a file. However I want it to be padded. Meaning always in the MM/DD/YY format (always having 8 characters, including the 2 forward slashes). If the files date is Janurary 9th, 2002, I want it to return 01/09/02 (8 chars like I want) instead of 1/9/02 (6 chars -- not good). How do I go about doing so? Thanks in advance, Nico
|
|
Wed Jan 09, 2002 6:55 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
Re: manipulating date format. |
|
Yes, it can be done. To answer your question I need to know how you use the returned date value, a script fragment would be helpful. : I am using the FileDate to get the date of a file. However I want it to be : padded. Meaning always in the MM/DD/YY format (always having 8 characters, : including the 2 forward slashes). If the files date is Janurary 9th, 2002, : I want it to return 01/09/02 (8 chars like I want) instead of 1/9/02 (6 : chars -- not good). : How do I go about doing so? : Thanks in advance, : Nico
|
|
Wed Jan 09, 2002 7:44 pm |
|
 |
nico
Joined: 08 May 2001 Posts: 13
|
|
Re: manipulating date format. |
|
I'm actually just outputting it to my own log file. using: // Logging the check Concat( "", today, line2 ) Concat( line2, " ", line2 ) Concat( line2, now, line2 ) Concat( line2, "\tUP_CHECK", line2 ) Concat( line2, "\tHeartbeat:\t", line2 ) Concat( line2, up_file_date, line2 ) Concat( line2, "\t", line2 ) Concat( line2, up_file_time, line2 ) the var up_file_date is the one i want to be 8 char's at all times. I researched the @ - macro-parameters and tried using: Set down_file_date "@T"mm/dd/yy"" before the excerpt of code I pasted above but it still did not work. Whatcha think? : Yes, it can be done. To answer your question I need to know how you use the : returned date value, a script fragment would be helpful.
|
|
Wed Jan 09, 2002 7:50 pm |
|
 |
nico
Joined: 08 May 2001 Posts: 13
|
|
Re: manipulating date format. |
|
Blah I hope I'm not confusing you. In my previous post I said I used: Set down_file_date "@T"mm/dd/yy"" I meant to say that I tried to use Set up_file_date "@T"mm/dd/yy"" I got all my var's correct, don't worry :) -Nico : I'm actually just outputting it to my own log file. : using: // Logging the check : Concat( "", today, line2 ) : Concat( line2, " ", line2 ) : Concat( line2, now, line2 ) : Concat( line2, "\tUP_CHECK", line2 ) : Concat( line2, "\tHeartbeat:\t", line2 ) : Concat( line2, up_file_date, line2 ) : Concat( line2, "\t", line2 ) : Concat( line2, up_file_time, line2 ) : the var up_file_date is the one i want to be 8 char's at all times. : I researched the @ - macro-parameters and tried using: Set down_file_date : "@T"mm/dd/yy"" : before the excerpt of code I pasted above but it still did not work. : Whatcha think?
|
|
Wed Jan 09, 2002 7:53 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
Re: manipulating date format. |
|
One suggestion... single ConcatEx can replace a bunch of Concat calls Example: ConcatEx( today, " ", now, "\tUP_CHECK\tHeartbeat:\t", & up_file_date, "\t", up_file_time, line2 ) Even more efficient is the following example ConcatEx( today, " ", now, & "\tUP_CHECK\tHeartbeat:\t@T"mm/dd/yy"\t@T"hh:mm:ss"", line2 ) : Blah I hope I'm not confusing you. In my previous post I said I used: Set : down_file_date "@T"mm/dd/yy"" : I meant to say that I tried to use : Set up_file_date "@T"mm/dd/yy"" : I got all my var's correct, don't worry :) : -Nico
|
|
Wed Jan 09, 2002 8:22 pm |
|
 |
nico
Joined: 08 May 2001 Posts: 13
|
|
Re: manipulating date format. |
|
I don't understand how that will work. It is in the variable up_file_date that contains the files date. How are you using that date with the line: : "\tUP_CHECK\tHeartbeat:\t@T"mm/dd/yy"\t@T"hh:mm:ss"", That you wrote above. Instead of referencing the var up_file_date you are just using @T"mm/dd/yy" I don't understand how it knows that is coming from the var up_file_Date when you aren't using it anymore? Please explain, Nico : One suggestion... single ConcatEx can replace a bunch of Concat calls : Example: ConcatEx( today, " ", now, : "\tUP_CHECK\tHeartbeat:\t", & : up_file_date, "\t", up_file_time, line2 ) : Even more efficient is the following example : ConcatEx( today, " ", now, & : : "\tUP_CHECK\tHeartbeat:\t@T"mm/dd/yy"\t@T"hh:mm:ss"", : line2 )
|
|
Wed Jan 09, 2002 8:27 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
Re: manipulating date format. |
|
It is not coming from the up_file_date variable, I just saw from your code fragment that you initiate the variable using the Set statement then use the variable in Concat statements only. The up_file_date isn't being used in other places, is it? That variable simply contains the system date, not the date of some file. Why don't skip the "Set" step and insert the @-macro parameter (which is just a substitution value) directly into the output line? : I don't understand how that will work. It is in the variable up_file_date : that contains the files date. How are you using that date with the line: : That you wrote above. Instead of referencing the var up_file_date you are : just using @T"mm/dd/yy" I don't understand how it knows that is : coming from the var up_file_Date when you aren't using it anymore? : Please explain, : Nico
|
|
Wed Jan 09, 2002 9:55 pm |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|