You can translate the question and the replies:

Convert calenderweek and year to date

Hi guys, I am facing the following converting issue in denodo. I have to convert the formats yyww, yyyyww, wwyy and ww/yy into the date 'dd.MM.yyyy'. Does anyone of you have an solution for this problem I am facing right now? Thanks Johannes
user
06-04-2023 03:59:25 -0400
code

5 Answers

Greetings, Hope you are doing well. Denodo supports several date types to represent dates , time zones and interval values. Please check the following [Guide](https://community.denodo.com/docs/html/browse/8.0/en/vdp/vql/language_for_defining_and_processing_data_vql/data_types/data_types_for_dates_timestamps_and_intervals), descriptions along with conversion methods and examples are presented. If your date values are stored as text , you could make use of the [TO_LOCALDATE](https://community.denodo.com/docs/html/browse/8.0/en/vdp/vql/functions/datetime_functions/datetime_functions#to-localdate) conversion function. However, if the associated months and days are not stored in your repository, then they would likely default into a standard value such as January 1. Other option, is using the [FORMATDATE](https://community.denodo.com/docs/html/browse/8.0/en/vdp/vql/functions/datetime_functions/datetime_functions#formatdate) function provided that your values are stored in a datetime data type. Hope this helps !
Denodo Team
09-04-2023 07:04:24 -0400
code
Hi Denodo team, thanks for your answer, it brought me to new ways of thinking about this issue and I thought to solve the problem as follows: formatdate('dd.MM.yyyy',to_date('yyww',2315)). But now I have the problem that for example in year 2022 and 2021 I have an delay of 7 days. Query: formatdate('dd.MM.yyyy',to_date('yyww',2203),'WW') ,formatdate('dd.MM.yyyy',to_date('yyww',2103),'WW') Expected Result: 16.01.2022 17.01.2021 Actual Result: 09.01.2022 10.01.2021
user
12-04-2023 05:14:25 -0400
Greetings, Hope you are doing well. VQL Date and time functions typically rely on the date and time formatting system of Java. That is, taking in consideration different factors such as the first week of the year in which typically considers the first day of the first month of a year or the minimal days required to be considered a week; for instance, a week must be full, that is having 7 days . Therefore, depending on previous considerations day 1 of the year may be considered to belong to the previous year. In addition, the locale of view (i.e., local [internalization](https://community.denodo.com/docs/html/browse/latest/en/vdp/administration/creating_derived_views/advanced_configuration_of_views/search_methods_and_configuration_properties#internationalization-configuration) settings,i18n ) and query plays a role in determining the first day of the week (e.g., Sunday or Monday). Using above mentioned examples: ``` SELECT formatdate('dd.MM.yyyy',to_date('yyww',2203),'WW') FROM dual(); SELECT formatdate('dd.MM.yyyy',to_date('yyww',2103),'WW') FROM dual(); ``` In my case, Sunday is the first day of the week and the first week of the year has the first day of the first month of a year. Returned results are: ``` 09.01.2022 10.01.2021 ``` Following [reference](https://docs.oracle.com/javase/8/docs/api/java/time/temporal/WeekFields.html) elaborates on above explanation. Hope this helps !
Denodo Team
04-05-2023 04:53:00 -0400
code
Ok understandable. Would you have a solution to get the below conversions to the correct date format as shown below? Query: formatdate('dd.MM.yyyy',to_date('yyww',2203)) ,formatdate('dd.MM.yyyy',to_date('yyww',2003)) Actual Result: 09.01.2022 12.01.2020 Needed Result: 16.01.2022 12.01.2020 Thanks four your support!
user
05-05-2023 06:06:37 -0400
Greetings, Considering the factors detailed above the returned date results will be mostly related to your local settings. You could explore denodo custom functions capability, where you could create a new function (e.g. java functions such as the [following](https://www.geeksforgeeks.org/java-program-to-convert-string-to-date/)). Information about developing custom functions can be found [here](https://community.denodo.com/docs/html/browse/latest/en/vdp/developer/developing_extensions/developing_custom_functions/developing_custom_functions). Hope this helps !
Denodo Team
08-05-2023 03:58:20 -0400
code
You must sign in to add an answer. If you do not have an account, you can register here