Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2006
    Location
    INDIA
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MSSQL - get begining and end date

    Hello

    I am using MSSQL 2205.
    In one of my query, i get different dates. I want to use the month and year in another query. I am creating stored procedure. How can i use it.
    FE:
    Code:
    SELECT * from 
    (
     select empid, empname, joindate
     from employee
    where <conditions>
     order by joindate
    ) employee
    WHERE NOT EXISTS (
    SELECT * from Audit_T 
    WHERE empid=employee.empid and date between <how to use joindate here ? >)
    -- It returns:
    
    empid   empname  joindate
    1          a             01-01-07
    2          b             15-04-07
    3          c             10-02-08
    I want to use month and date of joindate date to query in another table using between clause
    01-01-07 and 31-01-07
    01-04-07 and 30-04-07 etc...
    How this can be achieved
    -------------------------
    Shailesh Patil
    -------------------------

  2. #2
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    Location
    St. Catharines, Ontario Canada
    Posts
    2,669
    Thanks
    6
    Thanked 150 Times in 141 Posts
    If you are using MSSQL then your post doesn't belong in this forum, but the general database forum. thread moved.


 

Tags for this Thread

Posting Permissions

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