Forum Discussion

dirkjs's avatar
dirkjs
Frequent Visitor
7 years ago

Incorrect syntax for DATETIME

I get an incorrect syntax error for the DATETIME strings in the example below:

CustomFiscalPeriods =
DATATABLE (
"Fiscal YearNumber", INTEGER,
"FirstDayOfYear", DATETIME,
"LastDayOfYear", DATETIME,
{
{ 2016, "28-06-2015", "2016-07-02" },
{ 2017, "2016-07-03", "2017-07-01" },
{ 2018, "2017-07-02", "2018-06-30" },
{ 2019, "2018-07-01", "2019-06-29" }
}
)
 

The syntax for "2015-08-16" is invalid.

I tested with Power-BI versions of June and May as well what gives the same error message!
My Input method is:
English (United States) and Belgian (Period) keyboard.

11 Replies

  • pbeye's avatar
    pbeye
    Resolver II

    I don't see "2015-08-16" in your formula, but I see "28-06-2015". Maybe that's the one causing the issue? Actually, when I test it out on my desktop both of those work for me. I'm using the July 2019 version.

     

    Maybe try adjusting it to match the other dates formats to see if that works.

    • dirkjs's avatar
      dirkjs
      Frequent Visitor

      Thanks for your response, but, both notations "28-06-2015" as "2015-06-28" do not work!

      • pbeye's avatar
        pbeye
        Resolver II

        Can you post a screen shot of what you see? It workes fine for me which is weird. You're trying to create a new table and not a column, correct?

  • v-lili6-msft's avatar
    v-lili6-msft
    Community Support

    hi, dirkjs 

    If it is the format error as below:

    CustomFiscalPeriods =
    DATATABLE (
    "Fiscal YearNumber", INTEGER,
    "FirstDayOfYear", DATETIME,
    "LastDayOfYear", DATETIME,
    {
    { 2016, "28-06-2015", "2016-07-02" },
    { 2017, "2016-07-03", "2017-07-01" },
    { 2018, "2017-07-02", "2018-06-30" },
    { 2019, "2018-07-01", "2019-06-29" }
    }
    )

    Please adjust it as below, then it should work well.

    Table = 
    DATATABLE (
        "Fiscal YearNumber", INTEGER,
        "FirstDayOfYear", DATETIME,
        "LastDayOfYear", DATETIME,
        {
            { 2016, "2015-06-28", "2016-07-02" },
            { 2017, "2016-07-03", "2017-07-01" },
            { 2018, "2017-07-02", "2018-06-30" },
            { 2019, "2018-07-01", "2019-06-29" }
        }
    )

    Result:

     

    Best Regards,

    Lin