Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to pass today's date as parameter?

Author  Topic 

navs
Starting Member

13 Posts

Posted - 2007-07-23 : 03:47:17
[code]

newMsg[1] = cmd.Parameters.Add("@txt_content", SqlDbType.NVarChar, 1000);
newMsg[1].Value = txt_content;

newMsg[2] = cmd.Parameters.Add("@date", SqlDbType.DateTime, 8).Value = DateTime.Now;
newMsg[2].Value = @date;

newMsg[3] = cmd.Parameters.Add("@txt_fromwhom", SqlDbType.NVarChar, 30);
newMsg[3].Value = txt_fromwhom;


[/code]

The part in bold is not working, how to pass current date as a parameter to a call to a stored proc in ASP.NET using C#?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-07-23 : 05:12:39
Try something like

FORMAT(DateTime.Now, "yyyy-mm-dd")


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -