To apply formats for Dates or Times other than the current date and time, use [format]
numero = 36[math]{08/14/2008}[/math] --> 733633[math]{10:12:07}[/math] --> 36727Now we can apply formatting using Days_To_Date, and formatting specifiers:
1. [Format Days_To_Date %m/%d/%y][math]{08/14/2008}[/math][/format]2. [format Days_To_Date %A, %B %d, %Y][math]{08/14/2008}[/math][/Format]3. [format Days_To_Date %A, %B %d, %Y]733633[/format]4. [format Days_To_Date]733633[/Format]5. [format Seconds_To_Time %I:%M:%S %p][math]{10:12:07}[/math][/format]6. [format Seconds_To_Time %I:%M:%S %p]36727[/format]Results would be:1. 08/14/08 2. Thursday, August 14, 2008 3. Thursday, August 14, 2008 4. 08/14/2008 5. 10:12:07 AM 6. 10:12:07 AMNote that the [date] formats are the same, but work specifically on the [date] tag, which resolves to the current date only. If you are retrieving dates from a database, use Format as above.TIPThe %d designator returns a 2 digit date (August 05, 2008), but for single digit dates, this looks bad. There's a workaround. Separate the components, and wrap the %d piece in [math] tags, and it will get rid of the leading zero.
[math][format days_to_date %d][math]{[date]}[/math][/format][/math]Another way would be using grep:
[grep search= 0&replace= ][format Days_To_Date %A, %B %d, %Y][math]{[date]}[/math][/format][/grep][format FormatSpec]Text or Number[/Format]Formats text or numbers in various widths or currency formats.To display numbers with various decimal points or currency formats, surround the number or text with a [format] context.
Numeric formatting works with comma separators for decimal point (non-US style, such as [format 6,2f][math]39/7[/math][/format] yields 7,46 instead of 7.46)
Example:[format 10.2f]99.5[/Format] (f stands for floating-point number)[format 10s]Hello[/format] (s stands for string of text)[format Days_To_Date %m/%d/%y]195462[/format][format Seconds_To_Time]49768[/format][format Seconds_To_Time %I:%M:%S %p]49768[/format][format thousands 14.2f]394363210[/format][format thousands 14,2f]394363210[/format][format thousands .3d]7[/Format] (d stands for decimal number)The number displays right-justified with enough preceding spaces and digits after the decimal point to fill the exact width of the format specifier. Text is left-justified, with enough spaces after it to exactly fill the width specifier.
| 99.50| (10 wide, 2 after the decimal)|Hello | (10 wide, text)|04/07/1997| (#days as a date)|13:49:28||01:49:28 PM| |394,363,201.00| (14 wide, number with thousands separator)|394.363.201,00| (14 wide, number with European thousands separator)|007| (3 wide, integer part of number only, zeroes preceding)Given a number 345.67, the following format specifiers will display as shown:
8.3f = | 345.670| (f stands for floating point)8.2f = | 345.67|8.1f = | 345.7| (notice rounding from .67 to .7)8.0f = | 346| (notice rounding from .67 to next higher integer) .5d = |00345| (notice no rounding, and preceding 0s to fill 5 digits)Optional date format -- to format a number as a date (the number must represent the number of days since Midnight, January 1st, 0000), use the optional date specifier and a date format, the same as from the [date] tag. Also see date and time [Math].
It is always advised to [format] your math operations as WebDNA is working on a deep fractional part of the number, rounded by the server processor, which can sometimes yield strange results: instead of getting a "0", you might obtain a 0.0000000000000001
To specify the precision of a number, we must use like [format .2f][math]25*34.567[/math][/format]. From version 8.6, you can use [math .2f]25*34.567[/math]
Format is used for text and numbers. Format will also apply formatting to dates and times provided they are converted to numbers first. To convert a date or time into a number, enclose them with curly braces, and wrap them in a [math] context. This will convert dates into number of days since 00/00/0000, and times into number of seconds since midnight. And then they can be wrapped in a format context for custom formatting.[math]{08/14/2008}[/math] --> 733633
[math]{10:12:07}[/math] --> 36727
1. [Format Days_To_Date %m/%d/%y][math]{08/14/2008}[/math][/format]
2. [format Days_To_Date %A, %B %d, %Y][math]{08/14/2008}[/math][/Format]
3. [format Days_To_Date %A, %B %d, %Y]733633[/format]
4. [format Days_To_Date]733633[/Format]
5. [format Seconds_To_Time %I:%M:%S %p][math]{10:12:07}[/math][/format]
6. [format Seconds_To_Time %I:%M:%S %p]36727[/format]
[math][format days_to_date %d][math]{[date]}[/math][/format][/math]
[grep search= 0&replace= ]
[format Days_To_Date %A, %B %d, %Y][math]{[date]}[/math][/format]
[/grep]
Numeric formatting works with comma separators for decimal point (non-US style, such as [format 6,2f][math]39/7[/math][/format] yields 7,46 instead of 7.46)
[format 10.2f]99.5[/Format] (f stands for floating-point number)
[format 10s]Hello[/format] (s stands for string of text)
[format Days_To_Date %m/%d/%y]195462[/format]
[format Seconds_To_Time]49768[/format]
[format Seconds_To_Time %I:%M:%S %p]49768[/format]
[format thousands 14.2f]394363210[/format]
[format thousands 14,2f]394363210[/format]
[format thousands .3d]7[/Format] (d stands for decimal number)
| 99.50| (10 wide, 2 after the decimal)
|Hello | (10 wide, text)
|04/07/1997| (#days as a date)
|13:49:28|
|01:49:28 PM|
|394,363,201.00| (14 wide, number with thousands separator)
|394.363.201,00| (14 wide, number with European thousands separator)
|007| (3 wide, integer part of number only, zeroes preceding)
8.3f = | 345.670| (f stands for floating point)
8.2f = | 345.67|
8.1f = | 345.7| (notice rounding from .67 to .7)
8.0f = | 346| (notice rounding from .67 to next higher integer)
.5d = |00345| (notice no rounding, and preceding 0s to fill 5 digits)
It is always advised to [format] your math operations as WebDNA is working on a deep fractional part of the number, rounded by the server processor, which can sometimes yield strange results: instead of getting a "0", you might obtain a 0.0000000000000001
To specify the precision of a number, we must use like [format .2f][math]25*34.567[/math][/format]. From version 8.6, you can use [math .2f]25*34.567[/math]
DOWNLOAD WEBDNA NOW!
This Technical Change History provides a reverse chronological list of WebDNA changes...
WebDNA LibrariesA list of available libraries for WebDNA...
WebDNA ModulesA list of the currently available modules...
[biotype]BioType is a behavioral biometrics WebDNA function based on ADGS research and development (from version 8...
F.A.QA compilation of some user's questions...
Tips and TricksA list of user-submitted tips ...
[writefile] functions allows you to perform a wide variety of tasks...
[showif][showif Comparison]Show This HTML[/showif]...
[getchars]Extracts a portion of the text (also known as substring or Mid$)...
[url][url]...
[shell][shell] is a way to use the command line with your webserver...
DB encryptionDatabase Automatic Encryption (from WebDNA 8...