cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Big_S
Level: Powered On

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
seadude
Level 10

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
seadude
Level 10

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
seadude
Level 10

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

Big_S
Level: Powered On

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
seadude
Level 10

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

Big_S
Level: Powered On

Re: Date Time combine save into SQL

THANK YOU SO MUCH! @seadude  🙂

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 306 members 5,884 guests
Please welcome our newest community members: