Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
rakeman23
New Member

Applying a duration to DateTime

Hello Gurus,

 

I'm a newbie in Power BI.  I just want to ask if my below syntax is correct.  I just want to create a custom column on which I want to apply a duration of +8 hours since Power BI is not showing the correct Date and Time (Timezone).  

Dates below Nov 11, 2022 are all displayed correctly.  However, the dates greater that Nov 15, 2022 are all in UTC format.  Thanks in advance.

===
= Table.AddColumn(#"Changed Type1", "PHCreatedDateTime", each if DateTime.From([Created]) > #datetime(2022,11,11,0,0,0) as datetime then DateTime.From([Created]) + #duration(0,8,0,0) else null)

===

1 ACCEPTED SOLUTION

Hello again @Daryl-Lynch-Bzy 

 

I got it now Sir.  Instead of null, I just put the DateTime.From([Created]) after else....  Many thanks again.  Cheers! 🍻

 

= Table.AddColumn( #"Changed Type1", "PHCreatedDateTime", each
if DateTime.From([Created]) > #datetime(2022,11,11,0,0,0)
then DateTime.From([Created]) + #duration(0,8,0,0) else DateTime.From([Created]), type datetime)

View solution in original post

3 REPLIES 3
Daryl-Lynch-Bzy
Community Champion
Community Champion

Hi @rakeman23 - I you thinking along the right line but I think you need to remove "as datetime"

 

= Table.AddColumn( #"Changed Type1", "PHCreatedDateTime", each 
  if DateTime.From([Created]) > #datetime(2022,11,11,0,0,0) 
  then DateTime.From([Created]) + #duration(0,8,0,0) 
  else null
, type datetime)

Hi @Daryl-Lynch-Bzy 

 

Thanks Sir... worked like a charm 🙂

 

Although the "null" at the end of the statement, made the dates null.. hehe..  Sorry, what I want is for the statement to do "nothing" instead of null so that it will preserve its value 

Apologies for the confusion.  What should I substitute to null?  Many thanks again

Hello again @Daryl-Lynch-Bzy 

 

I got it now Sir.  Instead of null, I just put the DateTime.From([Created]) after else....  Many thanks again.  Cheers! 🍻

 

= Table.AddColumn( #"Changed Type1", "PHCreatedDateTime", each
if DateTime.From([Created]) > #datetime(2022,11,11,0,0,0)
then DateTime.From([Created]) + #duration(0,8,0,0) else DateTime.From([Created]), type datetime)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.