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

Date Time combine save into SQL

Hi Guys,

 

Do you know how to combine datepicker and time to save into the database as one?

dateTime.PNG

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User
Super User

Re: Date Time combine save into SQL

Hi @Big_S . It depends on what data type the SQL field is. String? Numeric? Datetime? Datetime2?

Try a combination of the Concatenate and Text functions. Also check out the DateTimeValue function.

Something like:

Text(
    Concatenate(
        Text(datepicker.SelectedDate), 
        ddHour.Selected.Value, 
        ":", 
        ddMinute.Selected.Value
    ), "mm/dd/yyyy hh:mm:ss"
)

Also, we have a lot of fun with Time in the forums here. Search the forum for "Time after time" or "Time to party" for some really good examples of Time functions.

Good luck!

View solution in original post

Highlighted
Super User
Super User

Re: Date Time combine save into SQL

Hi @Big_S ,

 

Aha. This changes things a bit. It looks like you have one DataCard/Group with three values (date, hour, minute)(?).

- Use Concatenate Function to combine Hour/Min dropdowns along with the ":"

- Use Text Function to convert the combined text to time(7) format

- Then patch this value to each Time column accordingly

- You might also experiment with the PowerApps Time Function 

- I don't think there would be anything special required for Patching the Datepicker date.

 

You might also consider combining the date and time columns into a single:

I dont' directly use time(7) in SQL but rather datetime(2) then parse things on the display/analysis end to peel out times as needed. I also like datetimeoffset. It basically holds users local time, UTC, and timezone all in a single column.

 

Again, might be 1/2 dozen of one 6 of the other as you may have to parse these on the display/analysis end (data visualization) to compare certain values.

Good luck!

View solution in original post

4 REPLIES 4
Highlighted
Super User
Super User

Re: Date Time combine save into SQL

Hi @Big_S . It depends on what data type the SQL field is. String? Numeric? Datetime? Datetime2?

Try a combination of the Concatenate and Text functions. Also check out the DateTimeValue function.

Something like:

Text(
    Concatenate(
        Text(datepicker.SelectedDate), 
        ddHour.Selected.Value, 
        ":", 
        ddMinute.Selected.Value
    ), "mm/dd/yyyy hh:mm:ss"
)

Also, we have a lot of fun with Time in the forums here. Search the forum for "Time after time" or "Time to party" for some really good examples of Time functions.

Good luck!

View solution in original post

Highlighted
Helper V
Helper V

Re: Date Time combine save into SQL

Hi @seadude 

This is my table design im using time as data type how to apply your formula on this? 🙂

table.PNG

Highlighted
Super User
Super User

Re: Date Time combine save into SQL

Hi @Big_S ,

 

Aha. This changes things a bit. It looks like you have one DataCard/Group with three values (date, hour, minute)(?).

- Use Concatenate Function to combine Hour/Min dropdowns along with the ":"

- Use Text Function to convert the combined text to time(7) format

- Then patch this value to each Time column accordingly

- You might also experiment with the PowerApps Time Function 

- I don't think there would be anything special required for Patching the Datepicker date.

 

You might also consider combining the date and time columns into a single:

I dont' directly use time(7) in SQL but rather datetime(2) then parse things on the display/analysis end to peel out times as needed. I also like datetimeoffset. It basically holds users local time, UTC, and timezone all in a single column.

 

Again, might be 1/2 dozen of one 6 of the other as you may have to parse these on the display/analysis end (data visualization) to compare certain values.

Good luck!

View solution in original post

Highlighted
Helper V
Helper V

Re: Date Time combine save into SQL

THANK YOU SO MUCH! @seadude  🙂

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (10,590)