Results 1 to 4 of 4

Thread: DB2 Date

  1. #1
    Join Date
    Sep 2002
    Location
    uk
    Posts
    1

    Thumbs up Unanswered: DB2 Date

    Hello friends,
    I am working with db2 udb v7.1 with fixpack5. I am fiding a problem when the clients connect to the database and while retrieving the date fields.My database date format is dd/mm/yyyy and country code is set to 785.
    when the users access from the client(i.e. Powerbuilder) they are getting the date format as mm/dd/yyyy. this is been killing me for the last fortnight. So can u please guide me what i can do to get the database and clients to come on streamline.

    thnx
    kajol


    __________________

  2. #2
    Join Date
    Feb 2002
    Location
    Germany
    Posts
    141

    DB2 Date - You can use the CHAR function

    Hello Kajol,

    I suppose, PowerBuilder is making some conversion (ODBC Driver???). You can be sure that you get the same format when you use the CHAR() function and give the format as parameter.

    Example:
    SELECT CHAR(date_column, ISO) FROM... -> JJJJ-MM-DD
    SELECT CHAR(date_column, USA) FROM... -> MM/DD/JJJJ
    SELECT CHAR(date_column, EUR) FROM... -> DD.MM.JJJJ

    HTH,

    Rodney
    Rodney Krick

  3. #3
    Join Date
    Aug 2002
    Posts
    3

    Smile

    Hi Kajol,

    I had a similar problem in one of our projects where we used MSSQL. The client wanted the date to be entered into the database in whatever format the user entered from his local machine. But b'coz the server had a specific format, the date used be added to the table in the server format. So we had to change the field type in the table to Varchar.
    This may help you in solving your problem. All the best.

    Regards,
    Vishrant

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    just a brief comment to point out that databases do not store dates in any particular format

    microsoft sql/server, for instance, stores dates as very large integers

    so getting dates into and out of databases is just a matter of choosing the right syntax

    if users want to enter dates in their format of choice, that should be perfectly okay, because the database will convert the date no matter what format it's in

    as for output, the database has to convert the date no matter what format you want it displayed in

    now, every database has a default display format, so if users are getting dates returned from the database in a format they don't like, you just have to figure out the right syntax

    rudy
    http://rudy.ca/

Posting Permissions

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