| Author |
Topic |
|
amurark
Yak Posting Veteran
55 Posts |
Posted - 2011-09-23 : 12:59:17
|
| number commentsSR10 "*** 02/06/10 12:14:51(Sandeep Singh) ***hence resolving the ticket..*** 02/06/10 12:14:21(Sandeep Singh) *** time has been expired for the request...*** 02/06/10 08:10:42(Shiv Bhagwan) ***Please do the need full.*** 01/06/10 20:49:59(Shiv Bhagwan) ***.*** 01/06/10 20:46:11(Shiv Bhagwan) ***Kindly Do the nned full.*** 01/06/10 07:29:48(Abhishek .) ***team plz install the projector for conference room-103 - 12"SR100 "*** 10/06/10 11:08:39(Poras Kumar) ***As per user, projector is no more required,Hence, resolving the ticket as per user confirmation.*** 10/06/10 11:06:40(Poras Kumar) ***As per user, projector is no more required.Hence resolving the ticket as per user confirmation.*** 10/06/10 08:32:16(Shiv Bhagwan) *** Please arrange the projector at Masterpiece, 4th floor*** 10/06/10 08:14:04(Shiv Bhagwan) *** Please arrange the projector at Masterpiece, 4th floor*** 10/06/10 07:37:17(Abhishek .) *** Please arrange the projector at Masterpiece, 4th floorDate Timings Room No.8th June 9:30 to 11 am 401 9th June 9:30 to 11 am 40110th June 9:30 to 11 am 401 For any query please get in touch with Devyani (9711918534)"please tell me i want only date and time from the above field02/06/10 12:14:5110/06/10 11:08:39Ankita |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
vmvadivel
Yak Posting Veteran
69 Posts |
Posted - 2011-09-25 : 02:42:30
|
| CREATE TABLE #tblStripDT(Remarks VARCHAR(MAX))GOINSERT INTO #tblStripDT Values ('SR10 "*** 02/06/10 12:14:51(Sandeep Singh) ***hence resolving the ticket..*** 02/06/10 12:14:21(Sandeep Singh) ***time has been expired for the request...*** 02/06/10 08:10:42(Shiv Bhagwan) ***Please do the need full.*** 01/06/10 20:49:59(Shiv Bhagwan) ***.*** 01/06/10 20:46:11(Shiv Bhagwan) ***Kindly Do the nned full.*** 01/06/10 07:29:48(Abhishek .) ***team plz install the projector for conference room-103 - 12"')GoINSERT INTO #tblStripDT Values ('SR100 "*** 10/06/10 11:08:39(Poras Kumar) ***As per user, projector is no more required,Hence, resolving the ticket as per user confirmation.*** 10/06/10 11:06:40(Poras Kumar) ***As per user, projector is no more required.Hence resolving the ticket as per user confirmation.*** 10/06/10 08:32:16(Shiv Bhagwan) ***Please arrange the projector at Masterpiece, 4th floor*** 10/06/10 08:14:04(Shiv Bhagwan) ***Please arrange the projector at Masterpiece, 4th floor*** 10/06/10 07:37:17(Abhishek .) ***Please arrange the projector at Masterpiece, 4th floorDate Timings Room No.8th June 9:30 to 11 am 401 9th June 9:30 to 11 am 40110th June 9:30 to 11 am 401')GO--SOLUTION: Assuming always the content will come on the same position as shown in your samples!SELECT REVERSE(LEFT(REVERSE(LEFT(Remarks, CHARINDEX('(', Remarks)-1)),17)) FROM #tblStripDTGOBest RegardsVadivelhttp://vadivel.blogspot.com |
 |
|
|
amurark
Yak Posting Veteran
55 Posts |
Posted - 2011-09-26 : 13:42:43
|
| pls help meAnkita |
 |
|
|
amurark
Yak Posting Veteran
55 Posts |
Posted - 2011-09-26 : 13:48:45
|
| THNKU VadivelBNOW HOOW TO CONVERT IT IN DATEFORMAT I USE CAST BUT SHOWING ERROR OUT OF RANGE DATEVALUEAnkita |
 |
|
|
amurark
Yak Posting Veteran
55 Posts |
Posted - 2011-09-26 : 13:56:20
|
| Msg 8115, Level 16, State 2, Line 1Arithmetic overflow error converting expression to data type datetime.THIS EEROR GETING I AM Ankita |
 |
|
|
amurark
Yak Posting Veteran
55 Posts |
Posted - 2011-09-26 : 23:03:52
|
SELECT REVERSE(LEFT(REVERSE(LEFT(comments, CHARINDEX('(', comments)-1)),17)) FROM ocmqm1i got an error Msg 8116, Level 16, State 1, Line 1Argument data type text is invalid for argument 1 of left function.      Ankita |
 |
|
|
vmvadivel
Yak Posting Veteran
69 Posts |
Posted - 2011-09-27 : 23:04:04
|
| The query was written as per the sample record you have shown in your post! If it is failing then it is quite possible that you haven't given us good sample of data. Also based on the date format you are using in your system you need to make use of SET DATEFORMAT appropriately. For example, if your dates are going to be Day month year format then use the below script:SET DATEFORMAT DMYBest RegardsVadivelhttp://vadivel.blogspot.com |
 |
|
|
amurark
Yak Posting Veteran
55 Posts |
Posted - 2011-09-28 : 01:46:38
|
| 13/09/10 18:52:12if the range is above 12 it is showing errori am using this query select cast(convert(varchar(25),substring(comments,4,18),111) as datetime from tablename.then i get error when my range gets above the 13error is Msg 242, Level 16, State 3, Line 1The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.Ankita |
 |
|
|
vmvadivel
Yak Posting Veteran
69 Posts |
Posted - 2011-09-28 : 01:49:59
|
| I think its because there are only 12 months and so once it sees 13 an error would be thrown. Did you try changing the date format?SET DATEFORMAT DMYBest RegardsVadivelhttp://vadivel.blogspot.com |
 |
|
|
vmvadivel
Yak Posting Veteran
69 Posts |
Posted - 2011-09-28 : 01:56:43
|
| --This code block would throw an error--The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.SET DATEFORMAT MDYGODECLARE @dt VARCHAR(20)SET @dt = '13/09/10 18:52:12'SELECT CONVERT(DATETIME, @DT)GO--Now it will work!SET DATEFORMAT DMYGODeclare @dt VARCHAR(20)SET @dt = '13/09/10 18:52:12'SELECT CONVERT(DATETIME, @DT)Best RegardsVadivelhttp://vadivel.blogspot.com |
 |
|
|
amurark
Yak Posting Veteran
55 Posts |
Posted - 2011-09-28 : 02:23:24
|
| thnku lot2010-10-21 14:49:26.0002010-09-13 18:52:12.0002010-09-13 18:54:52.0002010-09-14 14:22:14.0002010-09-13 13:39:08.0002010-09-13 13:48:38.0002010-09-13 19:40:15.000i am geitng output like this now i want to convert it inot hours pls tell me howAnkita |
 |
|
|
vmvadivel
Yak Posting Veteran
69 Posts |
|
|
amurark
Yak Posting Veteran
55 Posts |
Posted - 2011-09-28 : 03:20:10
|
| are u on facebook vadivelAnkita |
 |
|
|
vmvadivel
Yak Posting Veteran
69 Posts |
|
|
|