By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,766 Members | 1,281 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,766 IT Pros & Developers. It's quick & easy.

Concat date and time in stored procedure

Soniad
P: 66
Hello,

I am passing date and time individually to stored procedure as parameters as follows :

Expand|Select|Wrap|Line Numbers
  1. Exec  mySP   '01/31/2009' , '5:03:56 PM' 
whithin this stored procedure, i have declared one variable (senddatetime varchar(50)) ,
i want to concat this date & time and want the date format value as

Expand|Select|Wrap|Line Numbers
  1. 01/31/2009  5:03:56 PM
how to do this in stored procedure, i used many conversion ways, but no solutions.


Regards,
"D"
Jan 31 '09 #1
Share this Question
Share on Google+
4 Replies


ck9663
Expert 2.5K+
P: 2,878
How does your stored proc look like?

-- CK
Jan 31 '09 #2

Soniad
P: 66
@ck9663
Here's part of Stored Procedure ,


Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE dbo.SendMsg_proc           
  2.  
  3. @Gdate datetime,          
  4. @GTime datetime,        
  5.  
  6.  
  7. AS           
  8. Begin 
  9.  
  10. Declare @DSentdttime as varchar(50)
  11.  
  12. set @DSentdttime = (select Convert(varchar,@Gdate,101) +' '+  Convert(varchar,@GTime,114))        
  13.  
  14. End


Regards,
"D"
Feb 1 '09 #3

ck9663
Expert 2.5K+
P: 2,878
Pass it as varchar.

--CK
Feb 1 '09 #4

Soniad
P: 66
@ck9663
Hello,

I declared variable as varchar , and now its working .
Thank you.

Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE dbo.SendMsg_proc            
  2.  
  3. @Gdate  varchar(25),           
  4. @GTime  varchar(25)              
  5.  
  6.  
  7. AS            
  8. Begin  
  9.  
  10. Declare @DSentdttime as varchar(50) 
  11.  
  12. set @DSentdttime = (select @Gdate +' '+ @GTime)         
  13.  
  14. End 
Regards,
"D"
Feb 1 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.