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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Nandor
Helper I
Helper I

Generate a date key

Hi,

 

I have a classical Date&Time column in my database.

I would need to add a new column generated from year, month and day.

 

For example: 20160905 for the 5th of september 2016.

 

Thank you,

Nandor

3 ACCEPTED SOLUTIONS
grapefruitmoon
Advocate I
Advocate I

In Power Query/M you could use:

 

Date.ToText([DateColumn], "yyyMMdd")

View solution in original post

tjd
Impactful Individual
Impactful Individual

Nandor -

 

Try this: DateInt = ([Year]*10000)+([Month Nbr]*100)+[DayOfMonth])

View solution in original post

Framet
Resolver II
Resolver II

Hi,

 

Some very valid suggestions, my personal choice would be to have the following calcualted column:

=FORMAT ( [YourDateField], "YYYYMMDD" )

 

Cheers

View solution in original post

5 REPLIES 5
cabc_xlorla
Advocate IV
Advocate IV

All excellent solutions!

1. Date.ToText([DateColumn], "yyyMMdd")

2. DateInt = ([Year]*10000)+([Month Nbr]*100)+[DayOfMonth])
3. =FORMAT ( [YourDateField], "YYYYMMDD" )

 

thanks everyone!

Framet
Resolver II
Resolver II

Hi,

 

Some very valid suggestions, my personal choice would be to have the following calcualted column:

=FORMAT ( [YourDateField], "YYYYMMDD" )

 

Cheers

tjd
Impactful Individual
Impactful Individual

Nandor -

 

Try this: DateInt = ([Year]*10000)+([Month Nbr]*100)+[DayOfMonth])

grapefruitmoon
Advocate I
Advocate I

In Power Query/M you could use:

 

Date.ToText([DateColumn], "yyyMMdd")

Thank you!

 

All three solutions work perfectly.

 

Best regards,

N

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