Re: how to convert varchar into smalldatatime

From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 09/17/04

  • Next message: Baner: "NOT IN Query Returns No Results"
    Date: Fri, 17 Sep 2004 22:08:06 +0530
    
    

    you can make use of CONVERT function. See following example.

    ex:
    create table dt_Tab (dt varchar(12))

    insert into dt_tab values ('31/12/75')
    insert into dt_tab values ('31/01/75')
    insert into dt_tab values ('28/02/75')

    --add column
    alter table dt_tab add date1 smalldatetime

    --update statement with CONVERT function and using syntax format "3". See
    more help on CONVERT function in books online.
    update dt_tab
    set date1 = convert (datetime,dt,3)

    -- 
    Vishal Parkar
    vgparkar@yahoo.co.in | vgparkar@hotmail.com
    

  • Next message: Baner: "NOT IN Query Returns No Results"