SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Split Date Time in SQL - Paramater and time
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

BriansOSullivan
Starting Member

Ireland
1 Posts

Posted - 02/24/2012 :  11:30:59  Show Profile  Reply with Quote
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 - 02/24/2012 :  11:37:38  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000