Use datetime as the input parameter or split the date and
time into two different columns
Abhinav Kumar
akumar@itmag.com.au
[quoted text, click to view] >-----Original Message-----
>Hi All,
>
>I have the following table structure
>
>CREATE TABLE [test]
>([dd] [datetime] NULL)
>
>I have a stored procedure to insert values to the above
table. The SP is invoked from a .NET application written
in C#.
[quoted text, click to view] >I have to store date time in UTC format.I am able to
convert local date time to UTC format in C# by following
code :
[quoted text, click to view] >
>DateTime _datetime = DateTime.Now;
>string _formattedDateTime = _datetime.ToUniversalTime
().ToString("s", DateTimeFormatInfo.InvariantInfo) + "Z";
>
>Eg. "2004-04-01T04:00:17Z". [the symbol Z means it is in
UTC].
>
>When I pass this value to
>The SP is as follows :
>
>CREATE PROCEDURE SP_Insert
> @dd Varchar(30)
>AS
>insert into test1 (dd) values(convert(datetime,@dd,126))
>GO
>
>when i execute the sp
>
>exec sp_insert '2004-04-01T04:00:17Z'
>
>I get error as "Syntax error converting datetime from
character string."
>
>I thought of storing the datetime as string in that
case how to convert the string to datetime (in UTC
format)?
[quoted text, click to view] >
>Any suggestions would be greatly appreciated...
>
>Thanks in Advance
>Keshav