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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors