
Announcements
Hi,
I am creating a new power apps, in one field users are copy and past the date time data(ex: 2023/01/27 10:30 AM), data type for this field as singlelinetext. We are using multiple copy paste date options, so we can't use datepicker.
I am using the submitform option to store the data in SharePoint list.
Before saving the data to SharePoint list, needs to change the datetime format data type single line text to date time.
Please some one help.
Hi @Nikilp ,
You can use the Text function to convert the single line text data to a date and time format. The Text function takes a date/time value and converts it to a string in a specified format.
For example, you can use the following formula to convert the single line text data to a date and time format and then submit it to a SharePoint list:
First, you'll need to create a variable to store the date and time data in the correct format:
Set(varDateTime, DateTimeValue(FieldName.Text))
Where FieldName is the name of the field that contains the single line text data, "yyyy/mm/dd hh:mm AM/PM" is the format you want the date and time to be displayed in, and Value() will convert the text to a number if it is a date format.
Next, you'll need to use the SubmitForm function to submit the data to the SharePoint list and use the variable to update the SharePoint list field for the date and time:
SubmitForm(CanvasForm); Patch(SharePointList, CanvasForm.LastSubmit, {DateTimeField: varDateTime});
Note that you will need to replace below:
"FieldName" with the actual name of the field that contains the single line text data,
"CanvasForm" with the name of the form that you are submitting,
"SharePointList" with the name of the SharePoint list that you are updating,
"DateTimeField" with the name of the date/time field in the SharePoint list.