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 2000 Forums
 SQL Server Development (2000)
 Passing Datetime to SQL server

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-08-31 : 10:29:08
Rahul writes "Hi All,
I have a Web application where user can type in the dates they would like to filter their query or pass to their stored procedure. Something like an adhoc reporting tool..
Now I am trying to figure out what is the best way to pass this information. Cause i am facing lot of problems due to regional settings.. Like Web server is in one settings and SQL server is in another.. So sometimes the query itself is failing and sometimes its bringing wrong date etc.. I have tried different date formats in string... Date objects etc but nothing seems like sure shot way to bag this issue..

Thanks in advance
Rahul"

nr
SQLTeam MVY

12543 Posts

Posted - 2006-08-31 : 10:36:21
Either send as a datetime or as string in format yyyymmdd (or yyyymmdd hh:mm:ss or yyyy-mm-ddThh:mm:ss).


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2006-08-31 : 11:49:06
your client app is responsible for getting the user input and correctly creating a valid date from it. If you have trouble doing that at the client, consult a forum for the particular language you are programming in (i.e., VB.NET).

Once your client has a valid Date (not a string formatted like a date, but an actual *date* value with the proper datatype), you simply pass that date value to SQL using parameters.

http://weblogs.sqlteam.com/jeffs/archive/2006/07/21/10728.aspx

- Jeff
Go to Top of Page
   

- Advertisement -