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.
| Author |
Topic |
|
vin
Starting Member
26 Posts |
Posted - 2003-03-25 : 04:02:02
|
| Hi folks,I am trying to assign current date to the in parameter of a SP if the user is explicity not sending the values.The code is like this...------------------------------------------------------alter proc test(@tablename VARCHAR(30),@start_dt datetime,@end_dt datetime,@tcol VARCHAR(2000) = null)Asbeginif @start_dt=''set @start_dt=getdate()if @end_dt=''set @end_dt=getdate()select @tablename,@start_dt,@end_dt,@tcolendgo-----------------------------------------------------exec test 'Lib_types',NULL,'2003-01-20 04:33:05.533',NULLo/p:---Lib_types NULL 2003-01-20 04:33:05.533 NULL ------------------The value is not getting assigned to the current date. Could somebody help me |
|
|
Bambola
Posting Yak Master
103 Posts |
Posted - 2003-03-25 : 04:23:29
|
| [quote]if @start_dt=''set @start_dt=getdate()if @end_dt=''set @end_dt=getdate()[quote]if ISNULL(@start_dt,'') = ''set @start_dt=getdate()if ISNULL(@end_dt, '') = '' set @end_dt=getdate()Bambola. |
 |
|
|
neil
Starting Member
29 Posts |
Posted - 2003-03-25 : 04:28:06
|
| You could try set @start_dt = select GETDATE() |
 |
|
|
vin
Starting Member
26 Posts |
Posted - 2003-03-25 : 04:31:38
|
| hi Bambolathanx a lotIt is working...thax againand also could u pls tell me how to get the yesterdays date |
 |
|
|
samsekar
Constraint Violating Yak Guru
437 Posts |
Posted - 2003-03-25 : 04:41:34
|
quote: how to get the yesterdays date
select getdate()-1Sekar~~~~Success is not a destination that you ever reach. Success is the quality of your journey. |
 |
|
|
Bambola
Posting Yak Master
103 Posts |
Posted - 2003-03-25 : 04:53:35
|
quote: and also could u pls tell me how to get the yesterdays date
Sure. select dateadd(dy,-1,getdate())Bambola. |
 |
|
|
|
|
|
|
|