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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
arsm
Frequent Visitor

Create a list from two timestamps in power query

Hello, I'm trying to create a list from two timestamp columns in power query 

I have two columns with date and hour 

Column 1                                           Column 2 

12/14/2023 10:00:00 AM            12/15/2023 13:00:00 AM 

 

Output im looking for in column 3 is list of date and hours 

                                                       Column 3 

                                                      12/14/2023 10:00 

                                                      12/14/2023 11:00 

                                                       12/14/2023 12:00

                                                                    .

                                                                    .

                                                                    .  

                                                          12/15/2023 13:00

 

I tried Number.from (coumn 1)..Number from(column2) and it's not working. it is working when column only has date or only hour. 

Is there a way to create a list with both date hour ...please help 

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @arsm ,

Please change the M function into this:

Table.AddColumn(#"Changed Type", "Custom.1", each List.DateTimes([Column1], Duration.TotalHours([Column2] - [Column1]) + 1 ,#duration(0,1,0,0)))

vjunyantmsft_0-1719968384912.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
arsm
Frequent Visitor

Hi Jennratten, Thank you for the code, is there a way to list hours  

this list shows as 12/14/2024 10:00:00 AM

                            12/15/2024 11:00:00 AM

Insted how can i list same date and list hours 

                            12/14/2024 10:00:00 AM

                            12/14/2024 11:00:00 AM

                            12/14/2024 12:00:00 PM....... 12/15/2024 1:00:00 PM

                                            

Please let me know if i can modify this code. 

arsm
Frequent Visitor

Hi @jennratten , Thank you for the code, is there a way to list hours  

this list shows as 12/14/2024 10:00:00 AM

                            12/15/2024 11:00:00 AM

Insted how can i list same date and list hours 

                            12/14/2024 10:00:00 AM

                            12/14/2024 11:00:00 AM

                            12/14/2024 12:00:00 PM....... 12/15/2024 1:00:00 PM

                                            

Please let me know if i can modify this code. 

Anonymous
Not applicable

Hi @arsm ,

@jennratten Thanks for your reply!

@arsm Just change the answer of @jennratten 's into:

= Table.AddColumn(#"Changed Type", "Custom", each List.DateTimes([Column1], Number.From([Column2]) ,#duration(0,1,0,0)))

vjunyantmsft_0-1719276226678.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept both of the answers as the solution to help the other members find it more quickly.

@Anonymous  Thank you for replying 

I was able to create a list but list wont stop at 12/15/2024 1:0:0 PM (column 2), it keeps going. 

how can i end the list at column 2 timestamp 

arsm_0-1719947862918.png

 

 

Anonymous
Not applicable

Hi @arsm ,

Please change the M function into this:

Table.AddColumn(#"Changed Type", "Custom.1", each List.DateTimes([Column1], Duration.TotalHours([Column2] - [Column1]) + 1 ,#duration(0,1,0,0)))

vjunyantmsft_0-1719968384912.png


Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

jennratten
Super User
Super User

Hi @arsm - this is how you can do it.

Table.AddColumn(#"Changed Type", "Duration", each List.DateTimes([Column1], Number.From([Column2]) ,#duration(1,1,0,0)))

jennratten_0-1718830800748.png

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors