cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ali_Nawaz
Helper III
Helper III

Default date format of powerapps

Hi PowerUsers, 

I'd like to know what is the default date format of powerapps and on what elements its based on (Web or Local machine datetime) ?

The issue I am facing is, when I read data from SQL in powerapps through gallery the date format it shows is "mm/dd/yyyy" whereas in SQL I have date format as "yyyy-mm-dd". 
I am aware of the fact that I can change the formats by using Text() function but as per my scenario I can not typecast the dates into text. 

I'd like to know if I can change the default date format of powerApps somehow ?
I want it to read the dates in "yyyy/mm/dd" format by default without any typecasting or conversion. 

A little scenario is, I have a column named PERIODSTARTDATE in SQL which is of datetime type. 
In powerApps I was comparing it with function Today() to extract certain set of record but now it has stopped working due to the date format as today is 06/01/2020 and somehow powerapps is reading it as 6th January 2020.
Things are getting messed up as I am using such comparisons in lots of places within my applications. 

Screenshot_1.png 

Looking forward to helpful responses as usual. 

Best Regards, 
Ali Nawaz

1 ACCEPTED SOLUTION

Accepted Solutions
v-yutliu-msft
Community Support
Community Support

Hi @Ali_Nawaz ,

Firstly, I'm afraid it's not supported to change the default date format in powerapps. It is set by system automatically.

Secondly, the key point of your problem is not date format. The key point is that sql connector does not support for direct date filters in powerapps.

 

The solution:

I do not think you need to change data type for these two problems, using AddColumns function is enough.

AddColumns function will only reshape the sql table, it will not change the original table's data. You could add a table with the date format that you want for problem1, add a table by using this formula :YEAR([date]) * 10000 + MONTH([date]) * 100 + DAY([date]), filter based on this formula.

 

Formula:
1)display the data format that you want:

AddColumns(sqltablename,"newdate",Text(PERIODSTARTDATE,"yyyy/mm/dd"))

the new date field will be column that you want.

 

2)filter based on date column:

Filter(
AddColumns(sqltablename,
           "startdate",
           Year(PERIODSTARTDATE) * 10000 + Month(PERIODSTARTDATE) * 100 + Day(PERIODSTARTDATE),
            "enddate",
           Year(PERIODENDDATE) * 10000 + Month(PERIODENDDATE) * 100 + Day(PERIODENDDATE)           
          ),
PAYCYCLEID=.....,
enddate>=Year(Today()) * 10000 + Month(Today()) * 100 + Day(Today()),
startdate<=Year(Today()) * 10000 + Month(Today()) * 100 + Day(Today())
)

 

 

 

Best regards,

 

Community Support Team _ Phoebe Liu
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

2 REPLIES 2
eka24
Super User III
Super User III

For comparison of Dates in SQL with powerapps, it better ypu create another date column from the Documentation:

 

"Direct date filters do not work for SQL Server. However, you can create a calculated column that will work. For instance, ALTER TABLE myTable ADD DateAsInt AS (YEAR([date]) * 10000 + MONTH([date]) * 100 + DAY([date])) and then filter on the calculated number column"

 

https://docs.microsoft.com/en-us/connectors/sql/

 

Then use that calculated column in your formulas.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

v-yutliu-msft
Community Support
Community Support

Hi @Ali_Nawaz ,

Firstly, I'm afraid it's not supported to change the default date format in powerapps. It is set by system automatically.

Secondly, the key point of your problem is not date format. The key point is that sql connector does not support for direct date filters in powerapps.

 

The solution:

I do not think you need to change data type for these two problems, using AddColumns function is enough.

AddColumns function will only reshape the sql table, it will not change the original table's data. You could add a table with the date format that you want for problem1, add a table by using this formula :YEAR([date]) * 10000 + MONTH([date]) * 100 + DAY([date]), filter based on this formula.

 

Formula:
1)display the data format that you want:

AddColumns(sqltablename,"newdate",Text(PERIODSTARTDATE,"yyyy/mm/dd"))

the new date field will be column that you want.

 

2)filter based on date column:

Filter(
AddColumns(sqltablename,
           "startdate",
           Year(PERIODSTARTDATE) * 10000 + Month(PERIODSTARTDATE) * 100 + Day(PERIODSTARTDATE),
            "enddate",
           Year(PERIODENDDATE) * 10000 + Month(PERIODENDDATE) * 100 + Day(PERIODENDDATE)           
          ),
PAYCYCLEID=.....,
enddate>=Year(Today()) * 10000 + Month(Today()) * 100 + Day(Today()),
startdate<=Year(Today()) * 10000 + Month(Today()) * 100 + Day(Today())
)

 

 

 

Best regards,

 

Community Support Team _ Phoebe Liu
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

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (21,796)