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
 SQL
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Abdullah
Starting Member

1 Posts

Posted - 07/23/2012 :  21:04:21  Show Profile  Reply with Quote
Hi,

1) Can someone send me a sql to extract the following from a string?

'384-06/16/2012' ----------------> 384 to be extracted
'2583-10/22/2012' ----------------> 2583 to be extracted
'82035-04/08/2012' ----------------> 82035 to be extracted

2) To find the time period between two date time stamps in seconds like

07/21/2012 15:28:28 minus 07/22/2012 15:28:27 = 86399 (or 86398 not sure) seconds.

Thanks,
Abdullah

visakh16
Very Important crosS Applying yaK Herder

India
47081 Posts

Posted - 07/23/2012 :  21:23:14  Show Profile  Reply with Quote
You can use below hints and try for yourself. Please dont expect spoonfed answers. Once you try and face any issue ,post and we will help.

1. have a look at CHARINDEX() function and LEFT function in books online

2.have a look at DATEDIFF() function

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.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