Home / code / asp

Formatting Numeric and date output,

On more then one occasion you'll have to print numbers with decimals.
1 divided by 4 is 0.25 but 1 divided by3 is 0.3333...

Formatnumber(number,decimals)

Example:

<%
number1=2.3333
response.write(formatnumber(number1,2))
%>

The result will look like:
2,33

We can do the same for dates.

today is ..28/03/2001 8:45:52
FormatDatetime(now(),vbgeneraldate) = 28/03/2001 8:42:52
FormatDatetime(now(),vblongdate) = Wednesday 28 march 2001
FormatDatetime(now(),vbshortdate) = 28/03/2001
FormatDatetime(now(),vblongtime) = 8:42:52
FormatDatetime(now(),vbshorttime) = 08:42

 

TOP

Latest script:

 

Books: