Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2003
    Location
    Texas
    Posts
    8

    Unanswered: Formating date string

    Hello to all and Happy Holidays -

    I am pulling a date from Sybase in the following format: (yyyymmdd). I need to change the date format to read: mm/dd/yyyy.

    I have been using Right and Left text strings but am not getting anywhere.

    Your suggestions are welcome.

    Aj

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Post your retrieval code. THere is most likely a simple (and easy) way to help you out ...

  3. #3
    Join Date
    Feb 2002
    Posts
    2,232
    If it is treated as a string:

    strDate = mid("yyyymmdd",5,2) & "/" & right("yyyymmdd",2) & "/" & left("yyyymmdd",4)

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    If it is being pulled down as a real date you can do the following:

    If IsDate(strDate) Then
    strDate = Month(strDate) & "/" & Day(strDate) & "/" & Year(strDate)
    End If

    Also, format(date,"mm/dd/yyyy")

  5. #5
    Join Date
    Dec 2003
    Location
    Texas
    Posts
    8
    The date code from Sybase is: 20060628

    Right$([EffectMatDate], 4), "-", Left$([EffectMatDate], 4)

    In theory this changes the date code to 06282006. I need it to look like 06/28/2006.

    I know this is probably very basic but I have been given this project based on corp. reductions and am trying to get up to speed as quickly as possible.

    Thank you for your help

  6. #6
    Join Date
    Dec 2003
    Location
    Texas
    Posts
    8
    Originally posted by rnealejr
    If it is treated as a string:

    strDate = mid("yyyymmdd",5,2) & "/" & right("yyyymmdd",2) & "/" & left("yyyymmdd",4)
    >> Aj <<

    Thanks - I do have to treat it like a string. I understand your suggestion but when I go to run it, I am being asked to Enter Parameter Value. Shouldn't it be taking it from the Sybase expression?

  7. #7
    Join Date
    Feb 2002
    Posts
    2,232
    Where are you putting this code - is it as an expression for a control source ?

  8. #8
    Join Date
    Dec 2003
    Location
    Texas
    Posts
    8
    Originally posted by rnealejr
    Where are you putting this code - is it as an expression for a control source ?
    ''

    I am creating a query that pulls its data from Sybase via ODBC connectors. I have several date fields that need to be format to look like mm/dd/yyyy.

    This particular code is being used in the FIELD cell of the column.

  9. #9
    Join Date
    Dec 2003
    Location
    Texas
    Posts
    8
    Originally posted by ajg68
    ''

    I am creating a query that pulls its data from Sybase via ODBC connectors. I have several date fields that need to be format to look like mm/dd/yyyy.

    This particular code is being used in the FIELD cell of the column.
    I have been able to get it to work based on your suggested string. My only issue is not applying the strDate to the fields that = 0

Posting Permissions

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