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
 SQL

Author  Topic 

Abdullah
Starting Member

1 Post

Posted - 2012-07-23 : 21:04:21
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

52326 Posts

Posted - 2012-07-23 : 21:23:14
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
   

- Advertisement -