# how to add time\_grants to metrics yml files

**URL:** <https://discourse.getdbt.com/t/how-to-add-time-grants-to-metrics-yml-files/10303>\
**Category:** Help\
**Tags:** dbt-cloud, semantic-layer\
**Created:** [October 11, 2023, 8:10pm UTC](https://discourse.getdbt.com/t/how-to-add-time-grants-to-metrics-yml-files/10303 "2023-10-11T20:10:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xuzheng](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/xuzheng/32/2628_2.png) [@xuzheng](https://discourse.getdbt.com/u/xuzheng)\
**Post date:** [October 11, 2023, 8:10pm UTC](https://discourse.getdbt.com/t/how-to-add-time-grants-to-metrics-yml-files/10303/1 "2023-10-11T20:10:55Z")

</div>

Hi All,  
currently is researching dbt sematic feature, but saw below two format to create the metrics. but seems second one always returns errors. wondering , is second version format is out of date? when use first type, how can we add time\_grains attribtue to the yml? tried to add time\_grants, but return error. if not add that attribute, when tried to run query against metrics, will get The metric xxxx does not have the provided time grain day defined in the metric definition. Anyone can help on this? what is the correct format for yml when using metrics? what is the standard query against the metrics? thanks  
select \* from {{metrics.calculate(  
metric(‘xxxx’),  
grain=‘day’,  
dimensions=[‘xx’]  
)  
}}

 ![image](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/2X/7/73369ef2b6b9fa7ebe5e018406cec4bf5435b193.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/2X/3/301fd557e7de67c1a9f8cfc14d62ea232afa7837.png)
