Probs in DateTime query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sonia.sardana
    New Member
    • Jul 2006
    • 95

    Probs in DateTime query

    1)create table emp(empid int,dob datetime)
    insert into emp values(1,'12/12/1950')
    insert into emp values(2,'12/12/1952')
    insert into emp values(3,'12/12/1948')
    insert into emp values(4,'12/09/1950')
    select * from emp

    I want to retrieve the those empid's of those employees who were born on year 1950.

    2) I want to ask that when we insert only date,time is also inserted by default 00.00.00.000. If i want that time is not insetde, what to do??
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    Originally posted by sonia.sardana
    1)create table emp(empid int,dob datetime)
    insert into emp values(1,'12/12/1950')
    insert into emp values(2,'12/12/1952')
    insert into emp values(3,'12/12/1948')
    insert into emp values(4,'12/09/1950')
    select * from emp

    I want to retrieve the those empid's of those employees who were born on year 1950.

    2) I want to ask that when we insert only date,time is also inserted by default 00.00.00.000. If i want that time is not insetde, what to do??

    1. Use the DATEPART function.

    2. By default it will be inserted. If you want it remove on display, use the CONVERT function.

    -- CK

    Comment

    Working...