Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2006
    Posts
    12

    Unanswered: Sybase convert date yyyymmdd to mm/dd/yyyy

    Hello,
    I have a date field from a text file in the format yyyymmdd. How can I convert this to mm/dd/yyyy format in Sybase?

    Any suggestions?

    Thanks!

  2. #2
    Join Date
    Jan 2003
    Location
    Geneva, Switzerland
    Posts
    353
    If you load the data to a date or datetime column the data in yyyymmdd format will be correctly interpreted.

    Now, if you want to format the date in a SELECT statement you'd do
    Code:
    select convert(varchar, date_column, 101) from the_table
    Michael

  3. #3
    Join Date
    Feb 2003
    Location
    Netherlands
    Posts
    63
    Note that if you set a date value into a date field, yyyymmdd isn't always assumed but this depends on your system values.

    You can either do a:
    Code:
    set dateformat ymd
    
    select convert(varchar,convert(datetime,"20070102"),101) /* convert back to char */
    to force yyyymmdd recognition

    or you can force the conversion:

    Code:
    declare @mydatefield datetime
    
    select @mydatefield = convert(datetime, "20070102", 112) /* 112 = ymd */
    
    select convert(varchar,@mydatefield,101) /* convert back to char */
    Offcourse you don't need the variable..

    Code:
    select convert(varchar,convert(datetime, "20070102", 112),101)
    Greetz,

    Bastiaan Olij

  4. #4
    Join Date
    Nov 2014
    Posts
    7
    I have encountered a similar problem with Screen Update. I resolved it. I attachment has the solution with screenshots.

    How to Change YYYYMMDD Format.pdf

Posting Permissions

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