Year/Month Pattern Format Specifier in LightSwitch 2012

Here we will see how to use the Year/Month Pattern Format Specifier in LightSwitch Visual Studio 2012.

Year/Month ("Y" or "y") Format Specifier

The "Y" or "y" Standard Format Specifier represents a custom date and time format string that is explained by the DateTimeFormatInfo.YearMonthPattern property.

Note:
 The custom format string is "yyyy MMMM".

Use the following procedure to create a sample showing how to use
the Year/Month Pattern Format Specifier on a Screen.

Step 1

Open the LightSwitch Application in Visual Studio 2012 and go to the Solution Explorer.

Solution Explorer

Right-click on "Data Sources" and choose "Add Table".

Add Table

The table appears in the Table Designer window. Insert the records in the following table.

Employee Table

Step 2

Now once again go to the Solution Explorer, right-click on "Screens" and choose "Add Screen".

Add Screen

The Add New Screen dialog box appears. Select the "Editable Grid Screen" from the Screen Template, inside screen information, choose "Employee" under screen data and provide some name to the Screen and click the "OK" button.

Add New Screen

The Screen Designer appears as shown below.

Screen Designer

Press F5 to run the application. Provide the information. We will get the following output. 

Output of Editable Grid Screen

Step 3

Now stop debugging the application. From the Table Designer select the "DOB" record as shown in the figure below.

Select DOB from Employee

Then go to the Format Pattern of the Property window in the Table Designer and either you can enter "Y" in the format pattern for Year/Month Format Specifier.


Y Format Pattern Properties

Or you can enter "y" in the format pattern property window as shown below.


y Format Pattern

Once again press F5 to run the application. This time we will get the following output.

Year Month Pattern Output


Similar Articles