cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

DateTime in form needs to be converted to Date in excel

I have a label LabelCurrentDate which currently have Today(),
But while onSelect property of Submit Button,
I mentioned DATE: LabelCurrentDate.Text. Its gives in Type Error stating "This type of argument 'DATE' does not match expected type 'DateTime'. Found 'type error'.

 

How to submit only date in excel. 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @admin_ewbinc,

Could you please share more details about the formula within the OnSelect property of the "Submit" button?

Do you use LabelCurrentDate.Text formula as value for the DATE column (Date Time type) in your data source?

Based on the error message that you mentioned, I think there is something wrong with the value (LabelCurrentDate.Text) you provided for the DATE column in your data source.

The DATE column in your data source is required to provided a Date Time value, but the result the LabelCurrentDate.Text  formula returned is a Text value.

I assume that you use Patch function to submit your data into your data source, please modify your formula as below:

Patch(
     'YourDataSource',
      Defaults('YourDataSource'),
      {
         Column1: "xxxx",
         ...
         DATE: DateTimeValue(LabelCurrentDate.Text),  /* <-- Modify here */
         ...
      }
 
)

In addition, I think it is not necessary to add a Label control to store the current date, and then reference it as value for the DATE column in your data source. Please also take a try with the following workaround:

Patch(
     'YourDataSource',
      Defaults('YourDataSource'),
      {
         Column1: "xxxx",
         ...
         DATE: Now(),  /* <-- Modify here */
         ...
      }
 
)

More details about DateTimeValue function, please check the following article:

DateTimeValue

 

Best regards,

Kris

Community Support Team _ Kris Dai
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

4 REPLIES 4
Helper III
Helper III

Can you provide a sample of your code?

 

 

It appears that you are passing a Text type to something that is expecting a Date/Time type...

Community Support
Community Support

Hi @admin_ewbinc,

Could you please share more details about the formula within the OnSelect property of the "Submit" button?

Do you use LabelCurrentDate.Text formula as value for the DATE column (Date Time type) in your data source?

Based on the error message that you mentioned, I think there is something wrong with the value (LabelCurrentDate.Text) you provided for the DATE column in your data source.

The DATE column in your data source is required to provided a Date Time value, but the result the LabelCurrentDate.Text  formula returned is a Text value.

I assume that you use Patch function to submit your data into your data source, please modify your formula as below:

Patch(
     'YourDataSource',
      Defaults('YourDataSource'),
      {
         Column1: "xxxx",
         ...
         DATE: DateTimeValue(LabelCurrentDate.Text),  /* <-- Modify here */
         ...
      }
 
)

In addition, I think it is not necessary to add a Label control to store the current date, and then reference it as value for the DATE column in your data source. Please also take a try with the following workaround:

Patch(
     'YourDataSource',
      Defaults('YourDataSource'),
      {
         Column1: "xxxx",
         ...
         DATE: Now(),  /* <-- Modify here */
         ...
      }
 
)

More details about DateTimeValue function, please check the following article:

DateTimeValue

 

Best regards,

Kris

Community Support Team _ Kris Dai
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

Here is my code. Patch( LeaveTable, Defaults(LeaveTable), { DATE:LableCurren tDate.Text, NAME: TextInputEmployeeName.Text,TOTALDAYS: TextInputTotalDays.Text,FROM: fromDate.value,TO: toDate.value,REASONFORLEAVE: TextInputReason.Text}} )

Hi admin_ewbinc,

 

I believe Kris is correct in the changes needed for your code to work. In the DATE variable, you need to pass a DateTime value, not a Text value -- Kris's first example code shows you how to wrap the text value inside a DateTimevalue() function to get the result you need.

 

In addition, unless you need to use "LableCurrentDate" elsewhere on the screen, you could just pass the date using the the Now() function which Kris described in the second code example.

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (5,518)