cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kriggo15
Responsive Resident
Responsive Resident

Storing date picker as variable string

I have a variable (SubmitValue) that I'm using to store a text variable. In one case, that is coming from a dropdown, and in this case it needs to come from a date picker (DatePicker1). I'm storing it in a string variable because I'm writing it back to a varchar datatype in sql server.

 

I've set the OnChange property of the date picker to:

 

Set(SubmitValue, (DatePicker1.SelectedDate))

 

 

I also have a label set to the variable name. When I choose a date (3/10/2020), the label comes across as:

 

1583812800000

 


How do I get it to come across as the actual date selected?

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User
Dual Super User

just change your current code to the following:

Set(SubmitValue, Text(DatePicker1.SelectedDate,DateTimeFormat.ShortDate))

That will format the date as a string and prevent it from converting to Ticks 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Join me at 365EduCon in Chicago on Sept. 26-30 where I'll be presenting on the Power Platform!

View solution in original post

6 REPLIES 6
mdevaney
Super User
Super User

@kriggo15 

I think you can convert the number to a date like this.  Let me know if it works for you.

Date(1970,1,1) + 1583812800000/(60*60*24*1000) )

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Pstork1
Dual Super User
Dual Super User

just change your current code to the following:

Set(SubmitValue, Text(DatePicker1.SelectedDate,DateTimeFormat.ShortDate))

That will format the date as a string and prevent it from converting to Ticks 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Join me at 365EduCon in Chicago on Sept. 26-30 where I'll be presenting on the Power Platform!
kriggo15
Responsive Resident
Responsive Resident

Hey there @mdevaney 


If I understood your code, I'm getting the same value:

Set(SubmitValue, DatePicker1.SelectedDate); Set(SubmitValue, Date(1970,1,1) + SubmitValue/(60*60*24*1000))


datepicker.png

@kriggo15 

Use the solution of @Pstork1 above.

kriggo15
Responsive Resident
Responsive Resident

@Pstork1 

I get an error when using your method:
datepicker2.png

Try changing the name of the variable.  It works for me without error, but it may be giving you trouble since the variable was already created with a data value rather than a string.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Join me at 365EduCon in Chicago on Sept. 26-30 where I'll be presenting on the Power Platform!

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,925)