XPages date field value changes from AM to PM - date

I have created a managed bean to handle monitoring field changes on an XPage. The application requires that all changes to fields be logged. I have integrated the bean into a custom control on the XPage and it is created/instantiated when the user toggles the control from read only to editable. There is one Date/Time field set up to display only the date. The Notes document field is also set to display only the date. When the bean is instantiated and the SSJS obtains the date via getComponent - it returns the date like this: mm/dd/yy 12:00 AM. I have another button configured to get all the updated field values when it's clicked. When I click the second button it flags the date field as having been changed when it hasn't. The "updated" value is: mm/dd/yy 12:00 PM. If I trigger the initial and update code in the first button I get AM for both values. When I trigger both initial and update after the control is switched to edit mode by itself I get PM for both values. So it seems that getComponent is returning different values based upon the partial refresh event for readonly to editable. I tried using the afterRender event, but still get the AM/PM problem. Has anyone else encountered this problem? If so, any solutions? Assuming it's an issue with the mode change, any suggestions on how to capture when the change is complete and then trigger my code?

The default value for a date/time field which only stores a date is 12:00 midday. That's to handle Daylight Savings Time adjustments and I suspect the Java Date() to NotesDateTime conversion is doing the manipulation. (NotesDateTimes that are date only are stored with no timezone, so any conversion of 12:00am across DST boundaries may end up changing the date, whcih you don't want; e.g. adjusting 6 June forward 6 months with a time of 12:00AM would change it to 5 Dec, because it would drop back an hour.
I would recommend setting a default value that includes 12:00PM

Related

How do I partially update a Date / Time picker value?

I'm trying to allow partial updates to a date/time picker: https://mui.com/x/react-date-pickers/getting-started/
The scenario is as follows.. I have a date/time set. And I just want to update the time from AM to PM.
Let's say the starting state is
If I click PM, it'll update the value in the input box to show PM. But then if you click outside of the popup to close it, it'll revert back to AM.
It looks like the only way to set the date/time is to set every date and time option to update it.
Is there a setting on the component to allow partial updates to the date/time as described, so that when closing the popup, it preserves the update?
Thanks.

SSRS Preset or Custom Date Selection on Report

I currently have a report with the ability to select a start and end date. I was curious if you could make have both preset and the option for a custom selection
Selection:
Current Week, or
Previous Week, or
Custom Date Range.
Thanks,
Take a look at cascading parameters.
The link above seems to focus more on getting your cascading parameter values from a query, but you probably don't want that for a date - as far as I am aware, setting Available Values for a date parameter limits you to a dropdown list of dates, instead of the calendar which is generally easier to use. It is still a good background on how cascading parameters work though.
To do this with expressions for the default start/end date, you would basically want the first parameter to be a choice between "Current Week", "Previous Week", and "Custom Date Range". You would display those labels to the user, but the values can be whatever you want - for my test I just used 1, 2, and 3.
Then, you would set up 2 more parameters, one for the start date and one for the end date. Make sure the data type is Date. You will want to set up default values for these based on the value of the first parameter. I would do this with an expression such as the expression below for the start date. You also may need to modify this a bit depending on how you define the week - is the "Current Week" just the previous 7 days, or is it the latest Monday through today, or something else, etc.
=Switch(
Parameters!FirstParam.Value = 1, DateAdd("d", -7, Today()),
Parameters!FirstParam.Value = 2, DateAdd("d", -14, Today())
)
In this case, you don't even need to account for the 3rd option, because if the user wants a custom date range then you do not want the start and end date to fill in with any default values. You would need a similar expression for the default end date as well.
Since you want the user to be able to enter a custom range as well if they were to select the third option, you do not want to fill in the Available Values for the start/end date parameters, as the user would then not be able to select any date (at least as far as I am aware - if there is a workaround to that, I would love to see it, as that would be something I would like to use myself).
A possible downside to this approach is that if the user begins by selecting Current Week and then changes their mind to Previous Week, the start/end dates will not change to the Previous Week. You can read more about why this happens here, but essentially: since the values that are already filled in after selecting Current Week are still valid (they are dates, which is the only criteria for those parameters since no available values are set up), they will not refresh after changing the selection. The fix for this is to define the Available Values, but as mentioned above, this will then stop the user from entering a custom date range.

SharePoint: Wrong Date in Word Template's Quick Part

I have a library with custom content type with .docx template.
I have a 'StartDate' and 'EndDate' fields in the content type which are mapped to quick parts in .docx template.
When I change the values of these two fields in item properties, it updates the values in document as well (as it's supposed to be).
PROBLEM
The values in the document are always one day off.
If for example I set the date to 15/04/2016, it shows 14/04/2016 on the document.
How can I make them equal?
The time zones and everything seems to be fine on SharePoint and on my local machine.
I believe this issue is being caused by the way SharePoint stores date and time values. From the SharePoint MSDN article on Converting Date and Time Values:
Microsoft SharePoint Foundation stores date and time values in Coordinated Universal Time (UTC) format, and almost all date and time values that are returned by members of the object model are in UTC format.
So when you enter a date and time into SharePoint in local time, SharePoint stores that information in Coordinated Universal Time (UTC). But when the mapped content control in Word retrieves the date/time value it receives the UTC equivalent of whatever your local date and time is (SharePoint itself automatically converts date and time values to your local time when displaying that information within its own user interface).
I think the best way to solve this would be to create calculated fields that are not displayed. The calculated fields would take the input date/time values from your 'StartDate' and 'EndDate' fields in the content type and correct them for your local UTC offset. You could then map the corrected calculated values to Quick Parts in your Word document.

Drupal 7 and Page Manager: add Selection rules based on dates

I have a content type article with a field date.
I am trying to fire a variant from Page Manager by defining a selection rule based on a date field.
What I am trying to do is applying this variant when
the node type is article
field date, start date < now < field date, end date
I can define the first condition but I can't figure out how to make a condition based on a date. Is it possible or not? I couldn't find more information about this.
Thanks
I managed to do this finally by writing a PHP Code Selection Rule.
I got from the exposed $contexts variable the start and end values for date field and I wrote a simple condition to check if "now" is in between the two dates.
Beware that the dates are stored in UTC format in the field and your site/users might be in a different timezone.

SSRS 2008 R2 Report Builder 3.0: Offset Date Default Start Time

I allow the user to enter in what start date and end date they need.I set my start and end date parameters to #Start and #End. They have no values stored in them, rather in my code I have
....Between #Start and #End.
The dates entered by the user gets passed into my program instead of me specifying what the user is allowed to enter in the parameter properties.
My problem is I want the default start of each date picked to be 5:00 AM Instead of 0:00 AM. This way when the user picks for example: 2/20 and 2/21, they can retrieve date from 5:00 AM- 5:00 AM. This enables my program to show data past midnight, which is necessary because my data stops at 3:00 AM.
You can use the DateAdd function to add 5 hours to get 2/20/2013 5:00 AM
Look at this:
=DateAdd("h",5,Parameters!StartDate.Value)
Edit
you can add this line of code in one of the following:
Dataset's parameters section
Right click on your dataset
click on parameters section
Click on the FX button, and put there the line of code
Use this when you use parameters to filter your SQL query
Report's field (i.e textbox, table cell etc..)
Right click on the field
Click on the field expression option, and put there the line of code
The result looks like that: