cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

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

Re: Storing date picker as variable string

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.

View solution in original post

6 REPLIES 6
Highlighted
Super User
Super User

Re: Storing date picker as variable string

@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."

Highlighted
Dual Super User
Dual Super User

Re: Storing date picker as variable string

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.

View solution in original post

Highlighted
Helper V
Helper V

Re: Storing date picker as variable string

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

Highlighted
Super User
Super User

Re: Storing date picker as variable string

@kriggo15 

Use the solution of @Pstork1 above.

Highlighted
Helper V
Helper V

Re: Storing date picker as variable string

@Pstork1 

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

Highlighted
Dual Super User
Dual Super User

Re: Storing date picker as variable string

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.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (7,342)