asna.com Sign In
How can I format date values in AVR for .NET? 
There are many ways to format date values using .NET's custom date formatting. Here are some examples:

Formatted date Format string
August 14, 2004 MMMM, dd yyyy
14-Aug-2004 dd-MMM-yyyy
2004-08-14 yyyy-MM-dd
08/14/04 MM/dd/yy
Saturday, August 14, 2004 dddd, MMMM dd, yyyy

The format string can be expressed as an argument to the ToString() method. Thus, you might use it like this (where Date is a *Date field with a value in it you want formatted:

     Date.ToString( "MMMM, dd yyyy" ) 

There are also many other equally powerful custom formatting codes for time values.

The DateTime class offers lots of formatting capabilities. Search Visual Studio's help for "custom date formatting" or click here to read about them at msdn.microsoft.com.

Pay particular attention to the case of formatting strings. They are case sensitive.

What if the date value is numeric?

If your date value is numeric, it's best to convert it to a *date value and then use the the custom date formatting as shown above. !purl 165'>Click here !/purl to read about how to convert numeric and string values into date data types

However, if you absolutely insist on attempting to format a numeric value to a date, you can do using custom numeric formatting to at least perform rudimentary formatting directly on the numeric value. In this case, let's assume your numeric date is in the format yyyymmdd. You could format it to display 2004-08-14 with this:

DclFld MyNumericDate Type( *Packed ) Len( 8, 0 )MyNumericDate.ToString( "0000-00-00" ) 
Related Articles
Article Downloads
 
Keywords:
dates
Article ID: 287 
Category: ASNA Visual RPG 
Applies To:  
Article Date: 1/1/2007