Results 1 to 7 of 7
  1. #1
    Join Date
    May 2002
    Posts
    47

    Unanswered: to_date equivalent

    What is tghe equivalent date function for Oracle's to_date function.

    I want to return a date stored as 2000-04-01 00:00:00.000
    as 04/01/2001

    -K

  2. #2
    Join Date
    Aug 2002
    Location
    UK
    Posts
    87
    You can use the convert function to change the output format of of dates.

    I.E Select convert(varchar(10),<MYDATE>,103)

    Convert converts the output for this column
    Varchar(10) is the format this will be converted to
    103 is the Standard British date format for SQL Server

  3. #3
    Join Date
    Aug 2002
    Posts
    15
    Actually, it looks as though you will want to use format mask 101, not 103. I am presuming the date is April 1, 2002 and you want it in MM/DD/YYYY format. You do this by using the CONVERT function with a format mask (you can view the various format masks using the online T-SQL reference from Query Analyzer).

    i.e. CONVERT(VARCHAR,date,101)

    Originally posted by WingMan
    You can use the convert function to change the output format of of dates.

    I.E Select convert(varchar(10),<MYDATE>,103)

    Convert converts the output for this column
    Varchar(10) is the format this will be converted to
    103 is the Standard British date format for SQL Server

  4. #4
    Join Date
    Aug 2002
    Location
    UK
    Posts
    87
    I didn't think it is clear if it is the American or English date format that is requested. Who would want american style dates

  5. #5
    Join Date
    May 2002
    Posts
    47

    convert

    I wanted American but I figured out the code once I relaized it was the convert function I needed.

    Thanks!

    -Kevin

  6. #6
    Join Date
    Aug 2002
    Location
    UK
    Posts
    87
    Oh well I guess I'm the only Brit here

  7. #7
    Join Date
    Dec 2001
    Location
    Toronto, Canada
    Posts
    335
    Actually I'm Canadian and we use code 103 as well. We try to keep some ties to the Motherland.
    MCDBA

Posting Permissions

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