There are few ways to change the format of the date fields
1. Using External Data Metadata
Change The date format when you load the date field using External Data Metadata (ie when loading CSV file and along with metadata json). Define the date field and its format like below
"type": "Date",
"format": "MM/dd/yyyy",
2. Using Data flow json file
If the datasets are created via data flow job, Add computed expression in the data flow json file to create a date filed
with the required format.
"computedFields": [
{
"name": "Mod_CreatedDate",
"type": "Date",
"saqlExpression" : "toDate(CreatedDate_sec_epoch)",
"format" : "dd-MM-yyyy"
}
]
Mod_CreatedDate is just the name of newly created Computed field.
3.On the dashboard, The date field is displayed as value table. We can SAQL expression in step element of Values table to create the required date field.
Sample code
"query": "q = load \"OpportunitiesExpectedToWin\";\nq = foreach q generate count() as 'count', toString(toDate('CreatedDate_sec_epoch'), \"dd-MM-yyyy\") as 'Mod_createdDate', 'AccountId' as 'Account Id';\nq = limit q 2000;",
"type": "saql",
in the above code, we are creating one field 'Mod_createdDate' with the format 'dd-MM-yyyy' from the createdDate field
Friends, Let me know if you know any other ways too.
Comments
Post a Comment