FormatDateAsText ( baseDate ; Format )
Rate this function: Average rating: 2.6 (5 votes) Discuss this Custom Function
Eilert Sundt, Eilert Sundt Systemdesign
http://www.eilert.no
Formats a date with a specifiable format
Sample Input:
FormatDateAsText( Date(9;30;2009) ; "YYYY-MM-DD" )
FormatDateAsText( Date(9;30;2009) ; "M/D/YY" ) |
|
Sample Output:
|
Description:
This custom function takes as input a date and a text representation of a date format and returns a formatted date as a text string.
The following formatting strings are supported:
M
MM
D
DD
YY
YYYY
Note: these functions are not guaranteed
or supported by BrianDunning.com. Please contact the individual
developer with any questions or problems.
This is my Custom Function and I want to
edit it
Discuss:Make a comment about this Custom Function (please try to keep it brief & to the point). Anyone can post:
|
Newest Custom Functions:
| 1. |
GroupRelationInfo ( FileTarget ; TableTarget ; Result ) |
| |
(Tue, Mar 16, 5:57am) |
| 2. |
GeoBox(latitude;longitude; radius) |
| |
(Mon, Mar 15, 11:04am) |
| 3. |
MonthNameList ( start; number; short ) |
| |
(Sun, Mar 14, 11:45pm) |
| 4. |
matchListAB( ListA ; ListB; match_Value; match_operator ; getN ) |
| |
(Sun, Mar 14, 10:29pm) |
| 5. |
Bin2Hex ( binary ) |
| |
(Sat, Mar 13, 10:08pm) |
| 6. |
SlideView (text) |
| |
(Sat, Mar 13, 8:40pm) |
| 7. |
HashFNV1a64 ( text ; empty ) |
| |
(Sat, Mar 13, 6:23pm) |
| 8. |
HashFNV1a32 ( text ; empty ) |
| |
(Sat, Mar 13, 5:55pm) |
 |
|
I couldnt get that to work as advertised.
Shouldn't it be something like this
// DateAsText ( TheDate ; Format )
// Supports YYYY and YY, MM and M ; DD and D formats
// separators should be set in Format (use a value list)
// not recursive
Let
(
[
TheYear = Right ( Year ( TheDate ) ; PatternCount (Format ; "Y") ) ;
TheMonth = Case ( Month ( thedate ) ≤ 9 ; Right ( "00" & Month ( thedate ) ; PatternCount ( Format ; "M" ) ) ; Month ( thedate ) ) ;
TheDay = Case ( Day ( thedate ) ≤ 9 ; Right ( "00" & Day ( thedate ) ; PatternCount ( Format ; "D" )) ; Day ( thedate ) ) ;
Simplified = Substitute ( Format ; ["YY" ; "Y" ] ; ["YY" ; "Y" ] ; ["MM" ; "M" ] ; ["DD" ; "D" ] )
] ;
Substitute ( Simplified ; [ "Y" ; TheYear ] ; [ "M" ; TheMonth ] ; [ "D" ; TheDay ] )
)
maarten, arnhem
September 30, 2009 3:14pm