It's not guaranteed that the current thread culture is the one that the
server will use for processing.
Rather, if you MUST use a literal in a constructed string, you would use
the format:
yyyy-MM-dd HH:mm:ss.fff
This will represent down to milliseconds (which is the highest
resolution of the datetime data type on SQL Server). You can choose to omit
anything from one point in the string on (for example, everything from hour
(HH) on), depending on the comparison being made.
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.comwrote in
message news:uY**************@TK2MSFTNGP05.phx.gbl...
Hi,
Just like that :)
//If you are using parameters THE PREFERRED WAY
com.Parameters.Add("@adate", SqlDbType.DateTime).Value = DateTime.Now;
//building the text
com.CommandText = String.Format("update T set aDate = '{0}' ",
DateTime.Now.ToShortDateString() );
--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
<hu********@gmail.comwrote in message
news:f9**********************************@s19g2000 prg.googlegroups.com...
>Hi,
How can I convert a value created from DateTime.Now() to the datetime
format that SQL Server recognises?
Thanks in advance.