Amazon.com Widgets

Convert DateTime to ODBC time format

Recent question on this side of the firewall…

 

Want a datetime in this format?

2004-06-21T11:29:01.9346744-08:00

 

In .NET Framework 2.0: DateTime.ToString(“o”) ;

In .NET Framework 1.0\1.1: DateTime.ToString(“yyyy-MM-ddTHH:mm:ss.fffffffzzz”);

 

Published 07 February 05 07:38 by BradA
Filed under:

Comments

# RichB said on February 8, 2005 12:13 AM:
Your .Net 1.0/1.1 solution is incorrect. The output will change depending on culture. Provide the invariant culture to the ToString() so that non-gregorian cultures aren't accidently used, and it would also be a good idea to escape the : tokens inside the string.
# Michele Bernardi said on February 8, 2005 12:28 AM:
Yes, please, a SIMPLE WAY to obtain the datetime in ODBC format!!!
# Tiernans Comms Closet said on February 8, 2005 4:17 AM:
# Andrea said on February 8, 2005 3:01 AM:
/* DateTime: */
DateTime dt = DateTime.Now;

/* Conversion: */
Console.WriteLine("1: " + dt.ToString("yyyy-MM-ddTHH\\:mm\\:ss.fffffffzzz"));

/* With culture */
string formatString= "yyyy-MM-ddTHH:mm:ss.fffffffzzz";
System.Globalization.CultureInfo CInfo= new System.Globalization.CultureInfo("en-US", true);
Console.WriteLine("2: " + dt.ToString(formatString,CInfo));
# Keith Patrick said on February 8, 2005 6:34 AM:
Is the "o" defined somewhere as a constant with any other common constants the method would use, or is the magic string gonna be it?
# David Pickett said on February 9, 2005 8:23 AM:
Somewhat-related side note: oddly, DTS doesn't allow you to import datetimes in this format--you have to remove the "T" in the middle. Unless, of course, I've missed something obvious (in which case, plese enlighten me :) ).
# Hello??? .... is this thing on?? said on February 11, 2005 5:27 PM:
# Convert MM - Common Metric to US Conversion Calculators » convertmm.com said on June 11, 2006 7:44 PM:
PingBack from http://convertmm.com/?p=41
# Convert MM - p2p.wrox.com Forums - convert MM/dd/yyyy to dd/MM/yyyy » convertmm.com said on June 20, 2006 4:56 PM:
PingBack from http://convertmm.com/?p=69
# Convert MM - Intel To Convert Arizona Factory To 300 MM Technology » convertmm.com said on July 10, 2006 12:25 AM:
PingBack from http://convertmm.com/?p=126
# Convert MM - Metric and English Conversions » convertmm.com said on July 20, 2006 1:12 PM:
PingBack from http://convertmm.com/?p=161
# Convert MM - IFP : Metric Conversion Tables : convert metric to imperial for … » convertmm.com said on July 22, 2006 12:31 PM:
PingBack from http://convertmm.com/?p=168
# Convert MM - Brad Abrams : Convert DateTime to ODBC time format » convertmm.com said on July 27, 2006 5:32 PM:
PingBack from http://convertmm.com/?p=183
# Convert MM - Brad Abrams : Convert DateTime to ODBC time format » convertmm.com said on August 4, 2006 5:24 AM:
PingBack from http://convertmm.com/?p=207
# Convert MM - Convert-Me.Com - online units conversion :: View topic … » convertmm.com said on August 12, 2006 10:03 PM:
PingBack from http://convertmm.com/?p=238
# Convert MM - MegaGlass.com - Calculator » convertmm.com said on August 21, 2006 4:54 PM:
PingBack from http://convertmm.com/?p=268
# Convert MM - Common Metric to US Conversion Calculators » convertmm.com said on August 30, 2006 4:22 AM:
PingBack from http://convertmm.com/?p=292
# Convert MM - Brad Abrams : Convert DateTime to ODBC time format » convertmm.com said on September 5, 2006 7:18 AM:
PingBack from http://convertmm.com/?p=309
# Convert MM - Brad Abrams : Convert DateTime to ODBC time format » convertmm.com said on September 8, 2006 8:36 AM:
PingBack from http://convertmm.com/?p=319
# Convert MM - Exist a Convert-Tool: .ov2 -> .csv that can be read by MM Speedcam Import Utility?! - MP3Car.com Forums » convertmm.com said on September 19, 2006 2:39 AM:
PingBack from http://convertmm.com/?p=346
# Convert MM - Convert mm to inches - conversion calculator » convertmm.com said on September 27, 2006 10:21 AM:
PingBack from http://convertmm.com/?p=373
# Convert MM - Convert MM To Inches Conversion Tool » convertmm.com said on September 27, 2006 4:22 PM:
PingBack from http://convertmm.com/?p=374
# Convert MM - Convert MM to Inches » convertmm.com said on October 3, 2006 3:02 PM:

PingBack from http://convertmm.com/?p=398

New Comments to this post are disabled

Search

Go

This Blog

Syndication

Page view tracker