Friday, February 7, 2014

Converting Times Between Time Zones

Leave a Comment

It is becoming increasingly important for any application that works with dates and times to handle differences between time zones. An application can no longer assume that all times can be expressed in the local time, which is the time available from the DateTime structure. For example, a Web page that displays the current time in the eastern part of the United States will lack credibility to a customer in eastern Asia. This topic explains how to convert times from one time zone to another, as well as how to convert DateTimeOffset values that have limited time zone awareness.
   
Coordinated Universal Time (UTC) is a high-precision, atomic time standard. The world’s time zones are expressed as positive or negative offsets from UTC. Thus, UTC provides a kind of time-zone free or time-zone neutral time. The use of UTC time is recommended when a date and time's portability across computers is important. (For details and other best practices using dates and times, see Coding Best Practices Using DateTime in the .NET Framework.) Converting individual time zones to UTC makes time comparisons easy.

VB.NET
Dim dateNow As Date = Date.Now      
Console.WriteLine("The date and time are {0} UTC.",TimeZoneInfo.ConvertTimeToUtc(dateNow))
C#.NET
DateTime dateNow = DateTime.Now;
Console.WriteLine("The date and time are {0} UTC.", TimeZoneInfo.ConvertTimeToUtc(dateNow));
If the date and time value does not represent either the local time or UTC, the ToUniversalTime method will likely return an erroneous result. However, you can use the TimeZoneInfo.ConvertTimeToUtc method to convert the date and time from a specified time zone. (For details on retrieving a TimeZoneInfo object that represents the destination time zone, see Finding the Time Zones Defined on a Local System.) The following code uses the TimeZoneInfo.ConvertTimeToUtc method to convert Eastern Standard Time to UTC.

VB.NET
Dim easternTime As New Date(2007, 01, 02, 12, 16, 00)
Dim easternZoneId As String = "Eastern Standard Time" 
Try 
   Dim easternZone As TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(easternZoneId)
   Console.WriteLine("The date and time are {0} UTC.", TimeZoneInfo.ConvertTimeToUtc(easternTime, easternZone))
Catch e As TimeZoneNotFoundException
   Console.WriteLine("Unable to find the {0} zone in the registry.",easternZoneId)
Catch e As InvalidTimeZoneException
   Console.WriteLine("Registry data on the {0} zone has been corrupted.",easternZoneId)
End Try
C#.NET
DateTime easternTime = new DateTime(2007, 01, 02, 12, 16, 00);
string easternZoneId = "Eastern Standard Time";
try
{
   TimeZoneInfo easternZone = TimeZoneInfo.FindSystemTimeZoneById(easternZoneId);
   Console.WriteLine("The date and time are {0} UTC.",TimeZoneInfo.ConvertTimeToUtc(easternTime, easternZone));
}
catch (TimeZoneNotFoundException)
{
   Console.WriteLine("Unable to find the {0} zone in the registry.",easternZoneId);
}                           
catch (InvalidTimeZoneException)
{
   Console.WriteLine("Registry data on the {0} zone has been corrupted.", easternZoneId);
}

Time Zone IDs (Compact 2013)

The Dynamic Daylight Savings Time (Dynamic DST) feature provides the following time zone IDs.

ID    Time zone name                    Time Difference Display string
0     Dateline Standard Time            (UTC-12:00)  International Date Line West
110   UTC-11                            (UTC-11:00)  Coordinated Universal Time -11
200   Hawaiian Standard Time            (UTC-10:00)  Hawaii
300   Alaskan Standard Time             (UTC-09:00)  Alaska
400   Pacific Standard Time             (UTC-08:00)  Pacific Time (US and Canada)
410   Pacific Standard Time (Mexico)    (UTC-08:00)  Baja California
500   Mountain Standard Time            (UTC-07:00)  Mountain Time (US and Canada)
510   Mountain Standard Time (Mexico)   (UTC-07:00)  Chihuahua, La Paz, Mazatlan
520   US Mountain Standard Time         (UTC-07:00)  Arizona
600   Canada Central Standard Time      (UTC-06:00)  Saskatchewan
610   Central America Standard Time     (UTC-06:00)  Central America
620   Central Standard Time             (UTC-06:00)  Central Time (US and Canada)
630   Central Standard Time (Mexico)    (UTC-06:00)  Guadalajara, Mexico City, Monterrey
700   Eastern Standard Time             (UTC-05:00)  Eastern Time (US and Canada)
710   SA Pacific Standard Time          (UTC-05:00)  Bogota, Lima, Quito
720   US Eastern Standard Time          (UTC-05:00)  Indiana (East)
840   Venezuela Standard Time           (UTC-04:30)  Caracas
800   Atlantic Standard Time            (UTC-04:00)  Atlantic Time (Canada)
810   Central Brazilian Standard Time   (UTC-04:00)  Cuiaba
820   Pacific SA Standard Time          (UTC-04:00)  Santiago
830   SA Western Standard Time          (UTC-04:00)  Georgetown, La Paz, Manaus, San Juan
850   Paraguay Standard Time            (UTC-04:00)  Asuncion
900   Newfoundland Standard Time        (UTC-03:30)  Newfoundland
910   E. South America Standard Time    (UTC-03:00)  Brasilia
920   Greenland Standard Time           (UTC-03:00)  Greenland
930   Montevideo Standard Time          (UTC-03:00)  Montevideo
940   SA Eastern Standard Time          (UTC-03:00)  Cayenne, Fortaleza
950   Argentina Standard Time           (UTC-03:00)  Buenos Aires
1000  Mid-Atlantic Standard Time        (UTC-02:00)  Mid-Atlantic
1010  UTC-2                             (UTC-02:00)  Coordinated Universal Time -02
1100  Azores Standard Time              (UTC-01:00)  Azores
1110  Cape Verde Standard Time          (UTC-01:00)  Cape Verde Is.
1200  GMT Standard Time                 (UTC)        Dublin, Edinburgh, Lisbon, London
1210  Greenwich Standard Time           (UTC)        Monrovia, Reykjavik
1220  Morocco Standard Time             (UTC)        Casablanca
1230  UTC                               (UTC)        Coordinated Universal Time
1300  Central Europe Standard Time      (UTC+01:00)  Belgrade, Bratislava, Budapest, Ljubljana,
1310  Central European Standard Time    (UTC+01:00)  Sarajevo, Skopje, Warsaw, Zagreb
1320  Romance Standard Time             (UTC+01:00)  Brussels, Copenhagen, Madrid, Paris
1330  W. Central Africa Standard Time   (UTC+01:00)  West Central Africa
1340  W. Europe Standard Time           (UTC+01:00)  Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna
1350  Namibia Standard Time             (UTC+01:00)  Windhoek
1400  E. Europe Standard Time           (UTC+02:00)  Minsk
1410  Egypt Standard Time               (UTC+02:00)  Cairo
1420  FLE Standard Time                 (UTC+02:00)  Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius
1430  GTB Standard Time                 (UTC+02:00)  Athens, Bucharest
1440  Israel Standard Time              (UTC+02:00)  Jerusalem
1450  Jordan Standard Time              (UTC+02:00)  Amman
1460  Middle East Standard Time         (UTC+02:00)  Beirut
1470  South Africa Standard Time        (UTC+02:00)  Harare, Pretoria
1480  Syria Standard Time               (UTC+02:00)  Damascus
1490  Turkey Standard Time              (UTC+02:00)  Istanbul
1500  Arab Standard Time                (UTC+03:00)  Kuwait, Riyadh
1510  Arabic Standard Time              (UTC+03:00)  Baghdad
1520  E. Africa Standard Time           (UTC+03:00)  Nairobi
1530  Kaliningrad Standard Time         (UTC+03:00)  Kaliningrad
1550  Iran Standard Time                (UTC+03:30)  Tehran
1540  Russian Standard Time             (UTC+04:00)  Moscow, St. Petersburg, Volgograd
1600  Arabian Standard Time             (UTC+04:00)  Abu Dhabi, Muscat
1610  Azerbaijan Standard Time          (UTC+04:00)  Baku
1620  Caucasus Standard Time            (UTC+04:00)  Yerevan
1640  Georgian Standard Time            (UTC+04:00)  Tbilisi
1650  Mauritius Standard Time           (UTC+04:00)  Port Louis
1630  Afghanistan Standard Time         (UTC+04:30)  Kabul
1710  West Asia Standard Time           (UTC+05:00)  Tashkent
1750  Pakistan Standard Time            (UTC+05:00)  Islamabad, Karachi
1720  India Standard Time               (UTC+05:30)  Chennai, Kolkata, Mumbai, New Delhi
1730  Sri Lanka Standard Time           (UTC+05:30)  Sri Jayawardenepura
1740  Nepal Standard Time               (UTC+05:45)  Kathmandu
1700  Ekaterinburg Standard Time        (UTC+06:00)  Ekaterinburg
1800  Central Asia Standard Time        (UTC+06:00)  Astana
1830  Bangladesh Standard Time          (UTC+06:00)  Dhaka
1820  Myanmar Standard Time             (UTC+06:30)  Yangon (Rangoon)
1810  N. Central Asia Standard Time     (UTC+07:00)  Novosibirsk
1910  SE Asia Standard Time             (UTC+07:00)  Bangkok, Hanoi, Jakarta
1900  North Asia Standard Time          (UTC+08:00)  Krasnoyarsk
2000  China Standard Time               (UTC+08:00)  Beijing, Chongqing, Hong Kong, Urumqi
2020  Singapore Standard Time           (UTC+08:00)  Kuala Lumpur, Singapore
2030  Taipei Standard Time              (UTC+08:00)  Taipei
2040  W. Australia Standard Time        (UTC+08:00)  Perth
2050  Ulaanbaatar Standard Time         (UTC+08:00)  Ulaanbaatar
2010  North Asia East Standard Time     (UTC+09:00)  Irkutsk
2100  Korea Standard Time               (UTC+09:00)  Seoul
2110  Tokyo Standard Time               (UTC+09:00)  Osaka, Sapporo, Tokyo
2130  AUS Central Standard Time         (UTC+09:30)  Darwin
2140  Cen. Australia Standard Time      (UTC+09:30)  Adelaide
2120  Yakutsk Standard Time             (UTC+10:00)  Yakutsk
2200  AUS Eastern Standard Time         (UTC+10:00)  Canberra, Melbourne, Sydney
2210  E. Australia Standard Time        (UTC+10:00)  Brisbane
2220  Tasmania Standard Time            (UTC+10:00)  Hobart
2240  West Pacific Standard Time        (UTC+10:00)  Guam, Port Moresby
2230  Vladivostok Standard Time         (UTC+11:00)  Vladivostok
2300  Central Pacific Standard Time     (UTC+11:00)  Solomon Is., New Caledonia
2310  Magadan Standard Time             (UTC+12:00)  Magadan
2400  Fiji Standard Time                (UTC+12:00)  Fiji
2410  New Zealand Standard Time         (UTC+12:00)  Auckland, Wellington
2430  UTC+12                            (UTC+12:00)  Coordinated Universal Time +12
2500  Tonga Standard Time               (UTC+13:00)  Nuku'alofa
2510  Samoa Standard Time               (UTC-11:00)  Samoa

Read More...

A Visual Explanation of SQL Joins

Leave a Comment

A Visual Explanation of SQL Joins


An SQL JOIN clause is used to combine rows from two or more tables, based on a common field between them.

The most common type of join is SQL INNER JOIN (simple join). An SQL INNER JOIN return all rows from multiple tables where the join condition is met.

Assume we have the following two tables. Table A is on the left, and Table B is on the right. We'll populate them with four records each.
 
id name       id  name
-- ----       --  ----
1  Pirate     1   Rutabaga
2  Monkey     2   Pirate
3  Ninja      3   Darth Vader
4  Spaghetti  4   Ninja
Let's join these tables by the name field in a few different ways and see if we can get a conceptual match to those nifty Venn diagrams.

INNER JOIN

SELECT * FROM TableA
INNER JOIN TableB
ON TableA.name = TableB.name

id  name       id   name
--  ----       --   ----
1   Pirate     2    Pirate
3   Ninja      4    Ninja
Inner join produces only the set of records that match in both Table A and Table B.

FULL OUTER

SELECT * FROM TableA
FULL OUTER JOIN TableB
ON TableA.name = TableB.name

id    name       id    name
--    ----       --    ----
1     Pirate     2     Pirate
2     Monkey     null  null
3     Ninja      4     Ninja
4     Spaghetti  null  null
null  null       1     Rutabaga       
null  null       3     Darth Vader
Full outer join produces the set of all records in Table A and Table B, with matching records from both sides where available. If there is no match, the missing side will contain null.

LEFT OUTER JOIN

SELECT * FROM TableA
LEFT OUTER JOIN TableB
ON TableA.name = TableB.name

id  name       id    name
--  ----       --    ----
1   Pirate     2     Pirate
2   Monkey     null  null
3   Ninja      4     Ninja
4   Spaghetti  null  null
Left outer join produces a complete set of records from Table A, with the matching records (where available) in Table B. If there is no match, the right side will contain null.

LEFT OUTER JOIN

SELECT * FROM TableA
LEFT OUTER JOIN TableB
ON TableA.name = TableB.name
WHERE TableB.id IS null

id  name       id     name
--  ----       --     ----
2   Monkey     null   null
4   Spaghetti  null   null
To produce the set of records only in Table A, but not in Table B, we perform the same left outer join, then exclude the records we don't want from the right side via a where clause.

FULL OUTER JOIN

SELECT * FROM TableA
FULL OUTER JOIN TableB
ON TableA.name = TableB.name
WHERE TableA.id IS null 
OR TableB.id IS null

id    name       id    name
--    ----       --    ----
2     Monkey     null  null
4     Spaghetti  null  null
null  null       1     Rutabaga
null  null       3     Darth Vader
To produce the set of records unique to Table A and Table B, we perform the same full outer join, then exclude the records we don't want from both sides via a where clause.

CROSS JOIN

There's also a cartesian product or cross join, which as far as I can tell, can't be expressed as a Venn diagram:
SELECT * FROM TableA
CROSS JOIN TableB
This joins "everything to everything", resulting in 4 x 4 = 16 rows, far more than we had in the original sets. If you do the math, you can see why this is a very dangerous join to run against large tables.
Read More...

How to create a directory or folder (Microsoft Windows XP, Vista, 7 and 8 )

Leave a Comment
Microsoft XP,7 and 8 users can create a folder several different ways, below is a listing of the different methods to create a folder.

My Computer

  1. Open My Computer or Windows Explorer
  2. Open the drive or folder you wish to create a folder on, for example, the C: drive.
  3. If you do not wish to create a folder in the root directory, browse to the location you wish to create a folder, and then click File, then Folder; or right-click on a blank portion of the folder, click New and click Folder.

New Windows Desktop folderWindows Desktop

  1. Get to the Windows Desktop.
  2. Right-click on any blank portion of the Desktop.
  3. In the menu that appears (like that shown in the picture to the right) click New and the Folder.
  4. A new folder will appear, type the name of the folder you want to use and then press enter.

Windows command line


See the below MS-DOS and Windows command line users section for information about creating a directory in the Windows command line.
MS-DOS and Windows command line users

To create a directory in MS-DOS or the Windows command line use the md or mkdir MS-DOS command. For example, in the below example we are creating a new directory called hope in the current directory.

mkdir hope 

Using Application

This all are long process to create directory or folder.Download small and simple application to create directory or folder.
Click here to download application



Download Link : Click here
Required tool : .NET Framework 2.0

VB.NET code to create directory


My.Computer.FileSystem.CreateDirectory("DirectoryPath")
Or
Imports System.IO

Directory.CreateDirectory("DirectoryPath")

Read More...