What date format do you want?
/ can't be in file name.
The following will resolve the date into international format: i.e. 20160727
date = Get ( CurrentDate )
; year = Year ( date )
; month = Month ( date )
; month0 = If ( month < 10 ; "0" & month ; month )
; day = Day ( date )
keywords: Thank you. Exactly what I needed.
1 of 1 people found this helpful
I use yyyymmdd (leading 0's for the month and day) as this makes the filename 'alpha-sortable'.
19990110.xlsx would then come after 19990101.xslx,
where 1999011.xslx might not.
Also keep in mind that TEXT exported (xml or not) with the '.xlsx' extension does not compress the file as this notes:
It is a combination of XML architecture and ZIP compression for size reduction.
You can apply the .xsl extension to XML (Open Office, Spreadsheet) text document and Excel will handle it correctly.
You may or may not have problems using the .xslx extension. It may depend upon platform: 1. creating the file and 2. reading the file. Just a few caveats to keep in mind in case you do run into problems.
1. So substitute:
; day = Day ( date )
; day0 = If ( day < 10 ; "0" & day ; day )
2. Is it safer then to use ".xls"?
2. "safer"? It may be just my preference working with XML and Excel on multiple platforms. I just wanted you to have something "in case". If what you have works, then use it.
I completely agree that leading zeros are needed with days also. Thanks tays01s and beverly for pointing out and fixing up my carelessness!
4 of 4 people found this helpful
Sometimes I want to avoid using if/case in calculation...
Let ( d = Get(CurrentDate) ; Year(d) * 10000 + Month(d) * 100 + Day(d) )
yes! that works well.
Ignorance speaking here because I'm unfamiliar with the above:
- What is the value of 'get(currentdate)' that for eg. Year(d) x 10000 gives, in this case, 2016? Sorry, I'd just like to understand what's going on underneath.
3 of 3 people found this helpful
The idea is:
2016 * 10000 = 20160000
JAN * 100 = 100
2nd = 2
NOW, add them together:
The calc is just a different way to get the same value as Keywords answer with my suggestion of leading zeros for day, too.
Test it out!
I'd already tested it. Brilliant. I was thinking there was some hidden value within 'get(currentdate) but you're just treating like text........
I've also just used substitute to replace the "/" with underscores "_".
Substitute ( Get ( CurrentDate ) ; "/" ; "_" )
Just another way to keep the file name "legal"
I've used that method, too, Phil. However long ago I needed the YYYYMMDD (or YYYY_MM_DD) so the "date" was there, the "date" was recognizable universally (ISO 8601), the "date" could be parsed back out as a datetime element, the "date" was sortable alphabetically and still be sorted as if it is a date - sequentially by the year, month & day.
I also decided the "_" was unneeded, took up space in long file names, and the "-" or "/" might break something else.
Just my 3 cents.