DAY_NAME Formula in UI_Field

  • 1
  • Question
  • Updated 2 years ago
  • Answered
In UI fields and today is Saturday 

I want to return days of week in 7 separate UI_fields

DAY_NAME( TODAY() )        returns Saturday
DAY_NAME( TODAY()-1 )     returns Friday
DAY_NAME( TODAY()-2 )     returns Friday
DAY_NAME( TODAY()-3 )     returns Friday
DAY_NAME( TODAY()-4 )     returns Friday
DAY_NAME( TODAY()-5 )     returns Friday
DAY_NAME( TODAY()-6 )     returns Friday
DAY_NAME( TODAY()-7 )     returns Friday

I must have formula wrong?
Photo of Bill Fox

Bill Fox

  • 8,900 Points 5k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,988 Points 20k badge 2x thumb
You have Excel on the brain Bill.  In Excel days are numbers and you can do this sort of math.  Skuid uses more standard date fields and you can't just do "Today() - 1" and expect to get a valid date for yesterday...

You can get what you are after with a combination of date formatting formulas and pre-populated date fields.  Unfortunately its not super clean.  For every day name you want to return you need two fields.  One is a UI Only Date field that is prepopulated with a default value like "N_DAYS_AGO:1" .   This returns the date field you need.   The second field merely reformats that date using the DAY_NAME function. 

(This begs a question - why do you need this list? There have to be better ways to get this done...)

Posted below are is some XML of an exploration page I created...  It may be helpful.

<skuidpage personalizationmode="server" showsidebar="false" useviewportmeta="true" showheader="false"> <models> <model id="NewModel" query="true" createrowifnonefound="true" datasource="Ui-Only" processonclient="true"> <fields> <field id="Today" displaytype="FORMULA" ogdisplaytype="TEXT" readonly="true" returntype="DATE" label="Today"> <formula>TODAY()</formula> </field> <field id="DayName" displaytype="FORMULA" ogdisplaytype="TEXT" readonly="true" returntype="TEXT" label="Format Date"> <formula>FORMAT_DATE("DD",TODAY())</formula> </field> <field id="DayName2" displaytype="FORMULA" ogdisplaytype="TEXT" readonly="true" returntype="TEXT" label="Day Name"> <formula>DAY_NAME(TODAY())</formula> </field> <field id="Yesterday" displaytype="DATE" ogdisplaytype="TEXT" readonly="false" returntype="TEXT" defaultvaluetype="fieldvalue" defaultValue="YESTERDAY" label="Yesterday"> <formula>VALUE(TODAY())-1</formula> </field> <field id="YesterdayDayName" displaytype="FORMULA" label="Yest Day Name" ogdisplaytype="TEXT" readonly="true" returntype="TEXT"> <formula>DAY_NAME({{Yesterday}})</formula> </field> <field id="Day2" displaytype="DATE" label="Day - 2" ogdisplaytype="TEXT" defaultvaluetype="fieldvalue" defaultValue="N_DAYS_AGO:2"/> <field id="Day - 2 Name" displaytype="FORMULA" label="Day - 2 Name" ogdisplaytype="TEXT" readonly="true" returntype="TEXT"> <formula>DAY_NAME({{Day2}})</formula> </field> </fields> <conditions/> <actions/> </model> </models> <components> <basicfieldeditor showheader="true" showsavecancel="true" showerrorsinline="true" model="NewModel" uniqueid="sk-1OLv-377" mode="readonly"> <columns> <column width="50%"> <sections> <section title="Section A"> <fields> <field id="Today" uniqueid="sk-1OLv-385"/> <field uniqueid="sk-1OLv-540" id="DayName"/> <field uniqueid="sk-1OLv-814" id="DayName2"/> </fields> </section> </sections> </column> <column width="50%"> <sections> <section title="Section B"> <fields> <field uniqueid="sk-1OLv-1261" id="Yesterday" readonly="true"/> <field uniqueid="sk-1OLv-1586" id="YesterdayDayName"/> <field uniqueid="sk-1OLv-1965" id="Day2"/> <field uniqueid="sk-1OLv-1946" id="Day - 2 Name"/> </fields> </section> </sections> </column> </columns> </basicfieldeditor> </components> <resources> <labels/> <javascript/> <css/> <actionsequences uniqueid="sk-1OLv-241"/> </resources> <styles> <styleitem type="background" bgtype="none"/> </styles> <pageregioncontents> <pageregioncontent uniqueid="__header"> <components> <skuidheader sticky="true"> <components> <wrapper uniqueid="sk-1OLv-204"> <components/> <styles> <styleitem type="background"/> <styleitem type="border"/> <styleitem type="size" height="custom"> <styles> <styleitem property="min-height" value="50px"/> </styles> </styleitem> </styles> </wrapper> </components> </skuidheader> </components> </pageregioncontent> </pageregioncontents></skuidpage>