Forum Discussion

PaulEaston's avatar
PaulEaston
Qrew Assistant Captain
5 years ago

Displaying Date field dates without dashes

I want to generate a good that looks like this:

REQ##-YYYYMMDD-######
where
REQ[Record ID#]-[From a Date Field]-[From a number field]
e.g.:
REQ12-20210218-123456

The formula I used in the formula field is: 

"REQ"&[Record ID#]&"-"&ToFormattedText([Date Received],"YYYYMMDD")&"-"&[Source ID]

It displays as:

REQ12-2021-02-18-123456

Close, but I would like to remove the dashes in the date field. How can I do this?



------------------------------
Paul Easton
------------------------------
  • PaulEaston's avatar
    PaulEaston
    Qrew Assistant Captain
    Okay, this is how I got it to work: 

    "REQ"&[Record ID#]&"-"&Part(ToFormattedText([Date Received],"YYYYMMDD"),1,"-")&Part(ToFormattedText([Date Received],"YYYYMMDD"),2,"-")&Part(ToFormattedText([Date Received],"YYYYMMDD"),-1,"-")&"-"&[Source ID]


    Probably a more elegant way to accomplish this, but this works.

    ------------------------------
    Paul Easton
    ------------------------------
    • BlakeHarrison's avatar
      BlakeHarrison
      Qrew Captain
      Rather than using the 'Part' function against a date field, you can use 'Month', 'Day', and 'Year'. I'd do something like this:
      var number y = Year([Date Received]);
      var text m = Right(ToText(100+Month([Date Received])),2);
      var tex d = Right(ToText(100+Day([Date Received])),2);
      
      "REQ" & List("-",[Record ID#],$y & $m & $d,[Source ID] ​


      ------------------------------
      Blake Harrison
      bharrison@datablender.io
      DataBlender - Quickbase Solution Provider
      Atlanta GA
      404.800.1702 / http://datablender.io/
      ------------------------------
      • PaulEaston's avatar
        PaulEaston
        Qrew Assistant Captain
        Thank you Blake.  Is there any disadvantage to use part, besides it being a bit of kludge?  Any performance impacts?  Just curious.

        ------------------------------
        Paul Easton
        ------------------------------