Find the answer to your Linux question:
Results 1 to 3 of 3
This is more of a T-SQL question and for anyone who knows a lot about SQL, it's a very basic novice question so, bear with me When looking at this ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2008
    Posts
    17

    SQL syntax question


    This is more of a T-SQL question and for anyone who knows a lot about SQL, it's a very basic novice question so, bear with me

    When looking at this statement:
    IF DATEPART(dw, GETDATE()) = 7 OR DATEPART(dw, GETDATE()) = 1
    PRINT 'It is the weekend.'
    ELSE
    PRINT 'It is a weekday.'

    Why is there ()) after GETDATE? What is the purpose of the multiple ))'s?

  2. #2
    Linux Engineer Thrillhouse's Avatar
    Join Date
    Jun 2006
    Location
    Arlington, VA, USA
    Posts
    1,377
    GETDATE is a function so it requires the parenthesis as a function call. If you were to call GETDATE independently, it would just look like GETDATE(). So, the first closing paren closes the call to GETDATE. However, the result of this function call is passed as another paramater to the DATEPART function which requires 2 parameters. The second closing paren closes the call to DATEPART. Make sense?

  3. #3
    Just Joined!
    Join Date
    Jun 2008
    Posts
    17
    Yes, that makes a little more sense. Thanks.

  4. $spacer_open
    $spacer_close

Posting Permissions

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