dinsdag, april 18, 2006


getdate().tostring("MM/dd/yyyy") - MyCash.ToString("C")

Stop Using DatePart for Formatting Dates!
If you're still formatting dates as such:
lblDate.text = datepart("d",Now) & "/" & datepartt("m",now) & "/" & datepart("yyyy",now)
then stop this instant! Step away from the keyboard and no one gets hurt.
There are better ways in ASP.NET to format dates. You could replace the above line of code with:
lblDate.text = getdate().tostring("MM/dd/yyyy")
and end up with exactly what you needed. ASP.NET is full of great format strings. Remmeber the old FormatCurrency(MyCash) command? You can replace that with MyCash.ToString("C"). Download the .NET 2.0 SDK and look up "formatting strings"; you'll find all these goodies in there.

by Richard Dudley

Comments: Een reactie posten

Links to this post:

Een link maken

<< Home