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
 General SQL Server Forums
 New to SQL Server Programming
 Split Date Time in SQL - Paramater and time

Author  Topic 

BriansOSullivan
Starting Member

1 Post

Posted - 2012-02-24 : 11:30:59
Hi,

I am using a query below in sql query analyser and it is working well but ....

sy.start_dttm <= '2012-02-21 23:30:59.599' and
(sy.end_dttm >= '2012-02-21 23:30:59.599' or sy.end_dttm is null)and
pf.start_dttm <= '2012-02-21 23:30:59.599' and
(pf.end_dttm >= '2012-02-21 23:30:59.599' or pf.end_dttm is null)

I am wondering if it is possible to split the date time part into date and time. I want to leave the time alone as the time will never change. I will have a paramater for the date part and the time will remain the same. Is this possible?

I hope im explaining this correctly
Any advice is appreciated

X002548
Not Just a Number

15586 Posts

Posted - 2012-02-24 : 11:37:38
Are you using SQL Server 2008R2?



DECLARE @start_dttm datetime; SET @start_dttm = '2012-02-21 23:30:59.599'
SELECT @start_dttm AS start_dttm
, CONVERT(time,@start_dttm) AS start_dttm_time
, CONVERT(date,@start_dttm) AS start_dttm_date




Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -