cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Continued Contributor
Continued Contributor

Custom Format a Date Time

I have a date AND time field from SharePoint List Item.

I want to apply a custom format to it to shorten it.

 

So instead of "March 26th, 2020 16:25 PM" I would want "3/26 @4:25 PM"

 

I tried:

Text(ThisItem.'Next Steps Date', "[$-en-US]m/d @ hh:mm AM/PM" )
 
But it comes out as: "3/27/2001"?
 
THanks,
Terry
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Resident Rockstar
Resident Rockstar

Re: Custom Format a Date Time

@Mattw112IG 

Ah, I see, you appear to be mixing Date & DateTime data types, hence the error. It's like mixing Numbers & Text. My guess is that 'Start Date' is a Date ONLY field and 'Next Steps Date' is a Date & Time field. Is this correct?

 

When I use a similar code structure on my dataset I get the following:

(Notes: my code checks if ThisItem = "DailyPOB", if it is it gets the Date ONLY column, if not the Date & Time column. See the 3rd record has the Year 2001 (in red), same as yours)

Date_vs_DateTime_mismatch.jpg

The way I got it to work for me (above the red text), was to have two labels ie one for the Date ONLY field and one for the Date & Time field. These labels sit in the same location as each other ie one on top of the other.

 

Then, I set the Visible properties of each to:

// date ONLY field Visible property
If(ThisItem.DocumentType="DailyPOB",true,false)

// Date & Time field Visible property
If(ThisItem.DocumentType="DailyPOB",false,true)

Just replace my logic for yours.

 

The Text properties of these labels are ThisItem.'Date ONLY field' and ThisItem.'Date & Time Field' respectively.

 

 

 

View solution in original post

14 REPLIES 14
Highlighted
Resident Rockstar
Resident Rockstar

Re: Custom Format a Date Time

@Mattw112IG 

Try this

Text(ThisItem.'Next Steps Date', "m/d"&" @"&"hh:mm AM/PM")

 

Highlighted
Continued Contributor
Continued Contributor

Re: Custom Format a Date Time

displays the same?

Terry

Highlighted
Resident Rockstar
Resident Rockstar

Re: Custom Format a Date Time

Strange, it works for me. Did you copy and paste the code I suggested?

 

Dates_format using symbol.jpg

Highlighted
Continued Contributor
Continued Contributor

Re: Custom Format a Date Time

Yep, see below:

 

Starting date from SharePoint:

Annotation 2020-03-26 214256.png

 

After your edit:

Annotation 2020-03-26 214256b.png

 

 

Terry

Highlighted
Continued Contributor
Continued Contributor

Re: Custom Format a Date Time

Not sure if this is related but this is no longer working today, was working yesterday:

Text(
(Value(DataCardValue5.Text) - PRBurden) / Value(DataCardValue5.Text),
"[$-en-US].##0"
)
 
Used to return three places.. now only returning two??
 
Terry
Highlighted
Resident Rockstar
Resident Rockstar

Re: Custom Format a Date Time

@Mattw112IG 

There's a comma at the end of your formula, is your Text() formula part of an If() statement? Also, is this in a gallery or a Form? If a Form, what are the relevant properties of the DataCard?

 

For you three decimal places, try 000 instead of ##0.

Highlighted
Continued Contributor
Continued Contributor

Re: Custom Format a Date Time

Yes part of an if...

 

On a gallery

 

Thanks,

Terry

Highlighted
Resident Rockstar
Resident Rockstar

Re: Custom Format a Date Time

Can you share it? it maybe relevant. Seeing as the dates are mismatching I'd say the If() isn't making it to this statement.

 

To test this theory, try putting a label in your gallery with the above code only.

Highlighted
Continued Contributor
Continued Contributor

Re: Custom Format a Date Time

When I change, just this piece of the If, it changes the format.  So I think that is happening correctly... but full is:

 

If(
    ThisItem.'Next Steps' = "START",
    ThisItem.'Start Date',
    If(
        ThisItem.'Next Steps' = "Phone Screen" || ThisItem.'Next Steps' = "Interview" || ThisItem.'Next Steps' = "Final Interview",
        ThisItem.'Next Steps Date',
        ""
    )
)

 

This displays the full date and time.

 

When I change just the line I've shown in the clips, it changes to 2001.

 

Thanks,

Terry 

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 (8,542)