cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sasrsc
Resolver II
Resolver II

Convert milliseconds into a date and store as a date variable

I have a Date Time variable in a SP List called 'Occ Out Date' and I'm creating the variable MaxDate as the Max value. All OK. 
This by default creates a number which I assume is milliseconds.

 

UpdateContext(
    {
        MaxDate: Max(
            ThisAttendeeHotels,
            'Occ Out Date'
        )
    }
);

 
I can render this on a page in a label by doing...

" Max Check Out=" & Text(MaxDate,"[$-en-US]mm/dd/yyyy")

When I view the variable I see "it's a number" variable and the value is 16020273600000 which when converted in the label displays what I'd expect. 
All good so far...

But now I want to see the date difference between the MaxDate variable and a true date/time variable.
I'm not comparing the time only the date.
In my global variables I have a DateTime variable called DepartDate that reads 5/6/2021 5:21 PM.

There are 2 questions...
1) How do I compare the date value of the MaxDate and the DepartDate's?
2) Wouldn't it make more sense to create the MaxDate as a DateTime variable in the very beginning - if so, what would I do to create that as such in the very beginning?





1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

To convert MaxDate into a DateTime value use the DateTimeValue() function.  Then you can get the difference in days using the following.

DateDiff(DepartDate,DateTimeValue(Text(MaxDate,"[$-en-US]mm/dd/yyyy") ),Days)

Its an easy enough conversion and I don't see a reason to change what you are doing if the values display correctly in the label.

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

2 REPLIES 2
Pstork1
Dual Super User III
Dual Super User III

To convert MaxDate into a DateTime value use the DateTimeValue() function.  Then you can get the difference in days using the following.

DateDiff(DepartDate,DateTimeValue(Text(MaxDate,"[$-en-US]mm/dd/yyyy") ),Days)

Its an easy enough conversion and I don't see a reason to change what you are doing if the values display correctly in the label.

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Thanks PStork...

In the end I took your advice and kept the variable as a number...
I'm actually displaying an icon as a warning when they don't match...with the visible property reflecting...(in case this helps others)
DepartDate is a date/time variable
MaxDate is a number (reflected in milliseconds)



If(DateDiff(DepartDate,DateTimeValue(Text(MaxDate,"[$-en-US]mm/dd/yyyy") ),Days) <> 0, true,false)




Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (43,910)