Saturday, October 16, 2010

Date Formatting in C#

Date formatting in C# using string object

Specifier Description Output
d Short Date 20/10/1983
D Long Date 20 October 1983
t Short Time 21:20
T Long Time 21:20:59
f Full date and time 20 October 1983 21:20
F Full date and time (long) 20 October 1983 21:20:59
g Default date and time 20/10/1983 21:20
G Default date and time (long) 20/10/1983 21:20:59
M Day / Month 20 October
r RFC1123 date Thu, 20 Apr 1983 21:20:59 GMT
s Sortable date/time 1983-10-20T21:20:59
u Universal time, local timezone 1983-10-20 21:20:59Z
Y Month / Year October 1983
dd Day 20
ddd Short Day Name Thu
dddd Full Day Name Thursday
hh 2 digit hour 09
HH 2 digit hour (24 hour) 21
mm 2 digit minute 20
MM Month 10
MMM Short Month name Apr
MMMM Month name October
ss seconds 59
tt AM/PM PM
yy 2 digit year 07
yyyy 4 digit year 1983
: seperator, e.g. {0:hh:mm:ss} 09:20:59
/ seperator, e.g. {0:dd/MM/yyyy} 20/10/1983

Example using the specifier with data object

DateTime now = DateTime.Now;
Console.WriteLine(now.ToString("d"));

Friday, October 15, 2010

Download: SQL Server Sample Databases

SQL Server 2008R2 product sample databases are now available.
SQL Azure sample databases are now available.
SQL Server 2008 product sample databases are still available. If you are having difficulties with the current installer, please refer this Database Installer Help.
SQL Server 2005 product sample databases are still available.

For more help most sample databases and sample database business scenarios are documented on MSDN.

Monday, October 11, 2010

Zoom in/out with Visual Studio 2010

Visual Studio 2010 now supports the ability to zoom in and out of the text editor by using the mouse wheel. Ctrl + Mouse wheel up/down to Zoom in and Out. I love this feature for a couple of reasons:

  • Very nice when showing code to a group, such as during a demo to a large audience, or during team code reviews.
  • Makes it easy to pop in and out of your code to toggle between the “big picture” and “code level” views.

But what if you don’t have a mouse wheel? It turns out that there are keyboard shortcuts for this.

Functionality Command Keyboard Shortcut
Zoom in View.ZoomIn Ctrl+Shift+period
Zoom out View.ZoomOut Ctrl+Shift+comma

Friday, October 08, 2010

Disable User Account Control (UAC) For Administrators Only

If you can’t stand the User Account Control prompts, but you’d still like to retain a little bit of security, you can disable it for Administrator accounts only.

To configure this setting on Windows 7 / Vista Business and Ultimate, you can use the Local Security Policy configuration. Just type in secpol.msc into the Start menu search box and hit enter.

Brose down to Local Policies \ Security Options

image

Find the following in the list: “User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode” and double-click on it.

image

Change the setting to “Elevate without prompting”. You should be all done and good to go…

Note: Disabling UAC will lead to a less secure system, so better be warned :-)

Disabling User Account Control on Windows 7

Windows 7 makes it much easier to deal with UAC settings, and in fact you don’t have to completely disable UAC if you don’t want to. Just type UAC into the start menu or Control Panel search box or find how to go to UAC from my previous post.

image

Adjust the notification bar as per your choice. if you drag it all the way down to the bottom then it’ll be disabled entirely.

Note: Disabling UAC will lead to a less secure system, so better be warned :-)