cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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 @Anonymous ,

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
Super User

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 @Anonymous ,

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.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,295)