Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Date Formatting with data mapping

  1. #1
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658

    Date Formatting with data mapping

    Hello,

    When dealing with data mapping, how do you format a date field if the column is using a character type?
    Currently the value is displayed as 20050113 and I would like to see it as 1/13/2005.

    Thanks,
    Cory

  2. #2
    Lianja MVP
    Join Date
    Feb 2012
    Location
    Berea, KY, USA
    Posts
    2,185
    Quote Originally Posted by CGibson View Post
    Hello,

    When dealing with data mapping, how do you format a date field if the column is using a character type?
    Currently the value is displayed as 20050113 and I would like to see it as 1/13/2005.

    Thanks,
    Cory
    DTOC(STOD("{}"))

    ought to do it.

    hth,

    Hank

    PS: in your SET mapping, if the field is editable, you would use DTOC(CTOD("{}"),1).
    Last edited by HankFay; 2013-07-18 at 15:27.

  3. #3
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Hi Hank,

    Where would I use this ... input mask or somewhere else?

    Cory

  4. #4
    Quote Originally Posted by CGibson View Post
    Hi Hank,

    Where would I use this ... input mask or somewhere else?

    Cory
    You use Get data mapping and Set data mapping.
    Some examples here should help.

  5. #5
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Thanks for all of the help.
    The following worked for me:

    DTOC(keylookup("orders","orderid_search",order_det ails.orderid,orderdate))




    Also, I'm not sure who to report this to, although the lianjapedia example for STOD() uses dtos(). This gets extremely confusing when you are trying to learn and apply certain functions.

  6. #6
    Lianja Development Team barrymavin's Avatar
    Join Date
    Feb 2012
    Location
    UK, USA, Thailand
    Posts
    7,171
    Blog Entries
    22
    Hi Cory,

    You can test anything interactively in the "Console" workspace.

    Just type:

    ? dtos( date() )

    as an example.
    Principal developer of Lianja, Recital and other products

    Follow me on:

    Twitter: http://twitter.com/lianjaInc
    Facebook: http://www.facebook.com/LianjaInc
    LinkedIn: http://www.linkedin.com/in/barrymavin

  7. #7
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,842
    Hi Cory,

    Submit a Ticket (you will need to be logged into the website) and set the Category to 'Documentation' if you find any Lianjapedia errors and we'll get them fixed up.

    Thanks,

    Yvonne

  8. #8
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    Thank you Barry.
    I'm still getting used to and learning the Lianja environment.

    As per your request Yvonne, a ticket has been submitted.

  9. #9
    Senior Member
    Join Date
    Jul 2013
    Location
    Ontario, Canada
    Posts
    658
    All seems good except for saving.
    Changing a value, saving the grid then re-loading the grid places the value back to what it was.

    I'm assuming the issue exists with set mapping data.

    Get mapping data: DTOC(keylookup("orders","orderid_search",order_det ails.orderid,orderdate))

    Set mapping data: DTOC(CTOD(keylookup("orders", "orderdate",order_details.orderid,orderid_search)) ,1)

    Could someone help me as to the proper syntax required.

    Thanks,
    Cory

  10. #10
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Location
    Berkshire, UK
    Posts
    1,842
    Hi Cory,

    Sorry for the delay in responding.

    Firstly, I would put the DTOC() in your Get data mapping around the return value, rather than the whole expression - KEYLOOKUP() will return .F. (false) if the value is not found in the index which would lead to an attempt to DTOC() a logical value. So:

    Code:
    keylookup("orders","orderid_search",order_details.orderid,DTOC(orderdate))
    You can also add a 'not found expression' to KEYLOOKUP() - an alternative if the value is not found in the index, e.g. " / / ".

    For the Set data mapping, first make sure you have an index on the orders table so that you can search for the orderdate:

    Code:
    select orders
    index on dtos(orderdate) tag orderdate
    The value your Grid column after a change will be of character type - a date formatted using DTOC(). To look this up in the orderdate index, you will need to convert it to a DTOS() format ("YYYYMMDD"). We can use {} to get the current column value. Put it in quotes as it is a character string: "{}", then convert it to the format needed to search the index: dtos(ctod("{}")).

    Code:
    keylookup("orders","orderdate",dtos(ctod("{}")),orderid)
    The first parameter is the table that we want to look up into, the second parameter is the name of the index tag for that table that is going to be searched (created as above), the third parameter is what we are looking for in that index (the current column value correctly formatted) and the fourth parameter is the value we want back, the orders.orderid.

    Hope that helps,

    Yvonne

Tags for this Thread

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us