cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Advocate I
Advocate I

In Power Query/M you could use:

 

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

View solution in original post

Impactful Individual
Impactful Individual

Nandor -

 

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

View solution in original post

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
Advocate III
Advocate III

All excellent solutions!

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

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

 

thanks everyone!

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

Impactful Individual
Impactful Individual

Nandor -

 

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

View solution in original post

Advocate I
Advocate I

In Power Query/M you could use:

 

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

View solution in original post

Thank you!

 

All three solutions work perfectly.

 

Best regards,

N

Helpful resources

Announcements
secondImage

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

secondImage

Power BI Women

Join our monthly meetings and learning sessions.

secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors