web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Collecting Date and Time
Power Apps
Suggested Answer

Collecting Date and Time

(2) ShareShare
ReportReport
Posted on by 41
Hi Guys,
 
Im a bi of a Novice to Power Apps, and have a query around Collecting Dates & Times.
 
I have created a Text Input Box, which I am collecting the Date & Time using the the Now () Formula.
 
The issue I have, is that I am trying to collect this Time and Date to post into my Data Verse Table
 
Have tried a whole host of different Collect formulas, this is the latest one which failed, and below it the response from CoPilot
 
Collect(
    'Out Of Ours Tables',
    {'Date & Time':Date_Time.SelectedDate +Time(Value(HourValue1.Selected.Value),Value(MinuteValue1.Selected.Value)}
    );
 
Response from CoPilot
The expression was intended to collect a record into the 'Out Of Ours Tables' table with the current date and time based on the selected date, hour, and minute values.
However, there are multiple errors in the expression such as unexpected characters,
invalid names ('SelectedDate', 'HourValue1', 'MinuteValue1'), using the '.' operator on error values, invalid arguments for the 'Value' function,
and an incorrect number of arguments for the 'Add' function.
 
Any help would be hugely welcome
 
Thanks
Dan
DataVerse_Date.PNG
Categories:
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,978 Moderator on at
    Hi
     
    You don't use the + sign to add stuff like that.
     
    You should use the DateTimeValue function to convert all the stuff you have above into that
    So just format it as a string, wrap it with DateTimeValue 
     
    So like 
     
    DateTimeValue(Date_Time.SelectedDate & " " & HourValue1.Selected.Value & ":" & MinuteValue1.Selected.Value & " PM")
     
    Something like that. Since I cannot see your .Value values i am not sure its correct
     
    But give that a go
     
    Mark as the answer if this solves your issue please
     
  • DM-12091425-0 Profile Picture
    41 on at
    Hi FLMike,
     
    Have attempted this and it feels like its on the right track for sure (I originally copied the + stuff from another forum haha.
     
    The Date_Time is a Text Input Box with a Now() formulae so the user doesnt have to capture it manually or clicking buttons.
     
     
     
    The Table is a Data Verse table with a Date and Time Input format:
     
    Have tried a couple of times and its saying DateTimeValue is not a recognised property of the Date_Time Variable (Which is my text input using Now() Formulae) 
     
    Does this make sense?
     
    Thanks
    Dan
     
  • timl Profile Picture
    36,823 Super User 2026 Season 1 on at
    Hi Dan,
    The following is a safe way to retrieve the date and time irrespective of locale (eg, it'll work for US and countries that use the dd/mm/yy format)
     
    DateTime(Year(DateValue1.SelectedDate), 
             Month(DateValue1.SelectedDate), 
             Day(DateValue1.SelectedDate), 
             Value(HourValue1.Selected.Value), Value(MinuteValue1.Selected.Value)
    )
    
     
    If you're looking to add a record to the 'Out of Ours Tables', I'd suggest that you call the Patch function rather than Collect.
     
    Patch(
      'Out of Ours Tables',
      Defaults('Out of Ours Tables'),
      {
         'Date & Time':DateTime(Year(DateValue1.SelectedDate), 
             Month(DateValue1.SelectedDate), 
             Day(DateValue1.SelectedDate), 
             Value(HourValue1.Selected.Value), Value(MinuteValue1.Selected.Value)
           )
      }
    )
     
    This syntax assumes that you've added the datepicker and hour/time dropdown boxes to your screen. If you want to save the contents of a textbox called Textbox1, the syntax would look like this:
     
    Patch(
      'Out of Ours Tables',
      Defaults('Out of Ours Tables'),
      {
         'Date & Time':DateTimeValue(Textbox1.Text)
      }
    )
     
  • DM-12091425-0 Profile Picture
    41 on at
    Hi @timl
     
    Have attempted this, had to make a few changes based on the feedback from Co-Pilot, but to no avail :( 
     
    Patch('Global Out Of Hours Tables',Defaults('Global Out Of Hours Tables'),(Date_Time':DateTime(Year(DateValue1.SelectedDate),
             Month(DateValue1.SelectedDate),
             Day(DateValue1.SelectedDate),
             Value(HourValue1.Selected.Value), Value(MinuteValue1.Selected.Value)))
     
     
    This the response I get from Co-Pilot:
    The expression was intended to patch a new record into the 'Global Out Of Hours Tables' table with the date, month, day, hour, and minute values extracted from the DateValue1, HourValue1, and MinuteValue1 controls.
    However, there are multiple errors in the expression such as missing operators, incorrect syntax, unrecognized variables, and invalid arguments for the Value function and Patch function.
     
    Its also saying it does not like "DateValue1" Should I be replacing this with something? (Apologies for the noob questions)
     
     
    It was also expecting something here

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,055

#2
Valantis Profile Picture

Valantis 666

#2
11manish Profile Picture

11manish 666

Last 30 days Overall leaderboard