Results 1 to 9 of 9

Thread: Substring()

  1. #1
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273

    Unanswered: Substring()

    I'm trying to work out how to use the Substring Function but using the datetime in the field I'm looking at

    How can I write this Select statement as the error message I keep getting is

    Msg 8116, Level 16, State 1, Line 1
    Argument data type datetime is invalid for argument 1 of substring function.

    Code:
    SELECT SUBSTRING(START_DTTM,4,2) as 'Months'
    FROM dbo.REP_NON_PATIENT_EVENT_PERF_MAN

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Dates <> Strings. Look up DATEPART.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Or Year(), Month(), Day()
    George
    Home | Blog

  4. #4
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273
    Excellent Thanks

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Jez,
    Is there any reason why you post questions across so many different forums?
    I'm not talking about cross-posting here, more the fact that you are pretty active on here, SQLTeam and MSDN too!
    George
    Home | Blog

  6. #6
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273
    No real reason, I just dont like bothering the same people all the time

  7. #7
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Lol

    guess who's helping you here: http://forums.microsoft.com/msdn/Sho...41628&SiteID=1
    George
    Home | Blog

  8. #8
    Join Date
    Apr 2007
    Location
    Stalybridge, Manchester
    Posts
    273
    I guess its yourself then

    So its best to stick with the one forum then...

  9. #9
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by JezLisle
    So its best to stick with the one forum then...
    No, no. I was just intrigued that's all
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •