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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Today's Date, Split by Year, Month and Date

Hi all,

 

I have an API endpoint where I want to dynamically update the date to yesterday's date. However, the date needs to be in the format YYYY-MM-DD. This is my current attempt at doing this is by using this code:

 

Date.Year(DateTime.LocalNow()) & "-" & Date.Month(DateTime.LocalNow()) & "-" & Date.Day(DateTime.LocalNow()-1)

 

...in the context of the query it appears like this:

 

let
Source = Xml.Tables(Web.Contents("https://dataapi.xxxxxx.com/74daa799/v1/enterprise/73/events/xxxxxx/pages/created/2020-09-01;" & Date.Year(DateTime.LocalNow()) & "-" & Date.Month(DateTime.LocalNow()) & "-" & Date.Day(DateTime.LocalNow()-1) ))
in
Source

 

...when I run this I get the following error

 

Expression.Error: We cannot apply operator & to types Text and Number.
Details:
Operator=&
Left=https://dataapi.xxxxxx.com/74daa799/v1/enterprise/73/events/xxxxxx/pages/created/2020-09-01;
Right=2020

 

Can anyone suggest where I'm going wrong?

 

Thanks in advance,

 

Sam

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @Anonymous 

The error message says you are trying to concatenate text and numbers. Convert the numbers to text with Text.From( ) or similar

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

View solution in original post

2 REPLIES 2
AlB
Super User
Super User

Hi @Anonymous 

The error message says you are trying to concatenate text and numbers. Convert the numbers to text with Text.From( ) or similar

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

Anonymous
Not applicable

Perfect! You're a superstar, many thanks @AlB 

 

Sam

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors