Description:
This function returns the year, the month, the day and the day of the week (text) of a serial date.
Syntax: TIMESTRING (serial number, format_string)
The different options for this parameter are:
- %d=day of the Serial Date (in numbers);
- %b=month of the Serial Date (Abbrv);
- %B=month of the Serial Date (complete);
- %y=year of the Serial Date (Abbrv);
- %Y=year of the Serial Date (complete);
- %A=day of the week of the Serial Date in
words;
- %a=day of the week of the Serial Date in
words (Abbrv)
Remarks
Example
The TIMESTRING function can be used in any database where you have stored values for the number of the serial date and you want to return the year, the month or the day element from that serial date, in this case it's possible to access this value with the help of this function. This function displays the year as a number derived from the computation of the parameter supplied to this function.
=TIMESTRING (29058, %y) |
-Returns the year for this date but only the last 2 digits. (The year here is 1979, so the function returns an abbreviated value for the parameter %y, which is the value: "79". |
Let us take the example of a database in PowerOLAP that needs to access the value for the day, the month and the year from the given Serial Date. All these functions can be accessed from individual PowerOLAP functions or they can be accessed from one function which is "TIMESTRING" by using different parameters. In this case, we have written a formula in the appropriate cube in PowerOLAP, pulling in the value from the "Serial Date" field and then writing that value to this formula in order to calculate the various results of the "TIMESTRING" function. The formula then calculates the various TIMESTRING elements and the returns the requested information as per the parameter supplied as a string value.
The formulas shown above write values into the "DateData" cube to the dimension "Date Measure" and into the members "Month" ,"Day", "DayOfTheWeek" and the Year" members and all these values are derived from the "Serial Date" member and the function knows which value has to be extracted from the serial date, because the parameters "%B", "%d", "%A" and "%Y", these tell the function what values are to be calculated. The description for all these parameters and more is explained above.