Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2005
    Posts
    165

    Unanswered: Using GETDATE() to use current date...

    Hi. I have a stored procedure that looks for events on the current date. I tried using GETDATE() but i realized that is looking for the current date AND time. how can i use this to find only the current date? thanks a bunch for your help!

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    For what it's worth, I use a UDF for this. I just pass it the date I want to strip the time from - usually GETDATE(), since UDFs don't like GETDATE()

    Code:
    CREATE FUNCTION RemoveTime
    	(@dtmDate SMALLDATETIME)
    	
    RETURNS SMALLDATETIME   
    BEGIN
    --removes time from passed in date
    DECLARE @strDate VARCHAR(12)
    SET @strDate= CAST(MONTH(@dtmDate) AS CHAR(2)) + '/' + CAST(DAY(@dtmDate) AS CHAR(2))+ '/' + CAST(YEAR(@dtmDate) AS CHAR(4))
    SET @dtmDate=CONVERT(DATETIME, @strDate,101)
    RETURN @dtmDate
    END
    I'm sure there's an easier way, but this works
    Inspiration Through Fermentation

  3. #3
    Join Date
    Jan 2005
    Posts
    165
    thank you. it works like a charm now!!

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Look up DATEDIFF()
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

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

Posting Permissions

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