DateTime conversion to its sqlServer datetime float representation.

A

A.Neves

Hi,

I'm having a problem, I have a DateTime value in Portuguese representation
(dd-mm-yyyy) and I'm using SQLServer2005 with its default language English
(yyyy-mm-dd), so when I assemble a WHERE clause the date that goes to
SQLSErver is wrong.

I found that in SQLSErver I can convert a date to its sql server float
equivalent using cast(column_name as float).

I'd like to know if in C#, NetFramework is there a way to convert a DateTime
value to a float equivalent.

Thanks.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

I'd like to know if in C#, NetFramework is there a way to convert a
DateTime value to a float equivalent.

No, AFAIK,

What about if you use a parameterized query? You create a parameter of type
DateTime and the provider should be able to modify it as needed:


strSQL = "INSERT INTO FPPINCIDENT_SERVICEDETAILS (incseq_num,
inc_servicecode)" +
" VALUES (?)";
insertCommand = objSqlCeConn.CreateCommand();
insertCommand.CommandText = strSQL;

insertCommand.Parameters.Add(New SqlCeParameter("@inc_servtime",
SqlDbType.DateTime, 8));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top