Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Location
    UK
    Posts
    9

    Unanswered: Date Stamp Query ** RESOLVED **

    Hello.

    I have a Date Stamp field (format YYYY-MM-DD HH:MMS.000) and need to perform a SQL time comparison (between 17:00 and 18:00) and a separate date comparison (between Dec 01 2003 and Dec 08 2003) on this field.

    I'm having trouble with this - I've tried the Left and Right string functions and datepart but can't get them to work with these comparisons. How can I split up the relevant info and perform range comparisons on them?

    Can anyone help?

    Thanks.
    Last edited by sweevo; 12-17-03 at 12:22.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Use: Convert(Char(19), YourDate, 120)
    This creates a uniform and easily parsable string out of your date fields.

    blindman

  3. #3
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Code:
    declare @d1 datetime
    select @d1 = getdate()
    
    select convert (datetime,substring(convert(varchar(23),@d1,121),1,10),121) [DatePart],
    convert(datetime ,substring(convert(varchar(23),@d1,121),11,len(convert(varchar(23),@d1,121))-11),121) [TimePart]
    Hope this helps
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  4. #4
    Join Date
    Oct 2003
    Location
    UK
    Posts
    9
    Good stuff, I've got it working now.

    Thanks fellas.

Posting Permissions

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