Forum Discussion

Applicable88's avatar
Applicable88
Impactful Individual
5 years ago
Solved

M-formula for the Server offset

Hello,

 

since the server runs in UTC i have 2 hours difference. The problem is that I have a calculation running for specific days. I used the a formula to offset the hours: Time.Hour(DateTimeZone.SwitchZone(DateTimeZone.LocalNow(),2,0))

 

But I also have a date problem, for example now in my local time its actually 1 o'clock in the morning and its Friday. The server displays 11PM but is still on Thursday. So in my very long m formula I also have a condition for when weeknumber = 5 and so fourth. 

So since the report still thinks its Thursday these values won't be displayed. 

I tried this: 

Time.Hour(DateTimeZone.SwitchZone(Date.From(DateTime.LocalNow()),2,0))

But I got error.  I want a date to return, not time. 

I also need to correct when its really Friday around the midnight range:

Date.DayOfWeek(DateTime.FixedLocalNow(), Day.Sunday)

 

Anyone has an idea? Thank you very much in advance.

 

Best. 

  • You should be able to use this as your core expression and then wrap it in whatever you need to get your desired results.

     

    = DateTime.LocalNow() + #duration(0,2,0,0)

     

    For example, if you wrap it in Date.From, you will get tomorrows date (if it is >10 PM).

    Pat

     

1 Reply

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    You should be able to use this as your core expression and then wrap it in whatever you need to get your desired results.

     

    = DateTime.LocalNow() + #duration(0,2,0,0)

     

    For example, if you wrap it in Date.From, you will get tomorrows date (if it is >10 PM).

    Pat