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!

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!

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!

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? Smiley Happy

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!

Big_S
Level: Powered On

Re: Date Time combine save into SQL

THANK YOU SO MUCH! @seadude  Smiley Happy

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 125 members 4,516 guests
Please welcome our newest community members: