| View previous topic :: View next topic |
| Author |
Message |
adamrgolf
Joined: 28 Dec 2006 Posts: 385
|
Posted: Fri Mar 14, 2008 7:44 am Post subject: Simple date conversion (help) |
|
|
I'm not so good at using the FormatTime command and date conversion. I am writing a script to read the contents of a file and create a directory based on a "creation date".
the line in the file will always look like:
%%CreationDate: 03/13/08 10:15
then i need to create a directory based on this date in yyyyMMdd format to look like this:
20080313
I'll be using RegExMatch to extract the '03/13/08' from the file, but I'm confused on how to convert that date into the format I need for the file name.
Can anyone help me?
Thanks!!
Adam |
|
| Back to top |
|
 |
Klaus
Joined: 12 May 2005 Posts: 201 Location: Münster, Germany
|
Posted: Fri Mar 14, 2008 7:53 am Post subject: |
|
|
Hi, adamrgolf,
have a look at the SubStr(String, StartingPos [, Length])-function, which gives you all you need to build the desired directory name.
You only have to extract the two-digit portions of the date, complete it with a "20" for the century and concantenate these portions into your new directory name.
Hope it helps,
Klaus |
|
| Back to top |
|
 |
adamrgolf
Joined: 28 Dec 2006 Posts: 385
|
Posted: Fri Mar 14, 2008 7:55 am Post subject: |
|
|
Klaus, thanks for the response. I've considered this option prior to my first post, but am not sure of the range this "creation date" will be. I'm worried that some might be from the 1900's. I'd like to avoid inserting the "20" manually. Think you can help me figure that out .
Thanks again!
Adam |
|
| Back to top |
|
 |
Klaus
Joined: 12 May 2005 Posts: 201 Location: Münster, Germany
|
Posted: Fri Mar 14, 2008 8:15 am Post subject: |
|
|
Hi, adamrgolf,
so you have to decide about the century, I would like to propose to insert a "19", when the year's portion is > 79, all the others could receive a "20".
How about that? Could give you security until the year 2080!
Klaus |
|
| Back to top |
|
 |
adamrgolf
Joined: 28 Dec 2006 Posts: 385
|
Posted: Fri Mar 14, 2008 8:37 am Post subject: |
|
|
| Thats a good idea actually. Thanks for the input! |
|
| Back to top |
|
 |
Sakurako
Joined: 10 May 2007 Posts: 142
|
Posted: Fri Mar 14, 2008 9:53 am Post subject: |
|
|
| Code: | Test := "Test000000CreationDate: 03/13/08 10:15TestDone"
RegExMatch(Test, "CreationDate: (\d{1,2})/(\d{1,2})/(\d{1,2}) \d{1,2}:\d{1,2}", TimeCheck)
TimeCheck := (TimeCheck3 > 79 ? 19 : 20) SubStr(0 . TimeCheck3, -1, 2) SubStr(0 . TimeCheck1, -1, 2) SubStr(0 . TimeCheck2, -1, 2) |
_________________
|
|
| Back to top |
|
 |
adamrgolf
Joined: 28 Dec 2006 Posts: 385
|
Posted: Fri Mar 14, 2008 1:26 pm Post subject: |
|
|
| Thanks Sakurako & Klaus! |
|
| Back to top |
|
 |
|