Start & End of day in local timezone - node.js

I am trying to assign a date range - start/end dates for a process. The catch is that the start date should be the 00:00:00 of the start date and end date should be 23:59:59 of the end date in the timezone that my server is in.
Input is 4/4/2017
Following is my code snippet,
var pEnddate = formatDate (campaign.CMPGN_DTL_TX.CMPGN_END_DT, "yyyy-mm-dd 23:59:59");
pEnddate.then (function ( endDate ) {
var endDate1 = moment.tz (endDate, "America/Phoenix").format ();
campaign.CMPGN_DTL_TX.CMPGN_END_DT = endDate1;
}
It is going good for the first time and saving in UTC as "CMPGN_END_DT" : ISODate("2017-04-05T06:59:59.000+0000")
When I try editing it, the next time the date from my TS is coming as "CMPGN_END_DT" : ISODate("2017-04-05T06:59:59.000+0000"). But, the date is changing to the next date, which is CMPGN_END_DT" : ISODate("2017-04-05T23:59:59.000+0000") because I am hard-coding the time. I'm doing this to ensure I set it to the end of day. Because of this, every time I execute this code (which is when I'm updating the related process), the date is getting incremented by 1.
The only workaround I could figure out was to set it to the EOD without having to hard-code it. Is there some way I can achieve this?

Related

Regional Date format in excel VBA

I have a strange issues with date formatting - I am formatting dates as per below consistently - trying to get and display file details, below works fine with ldn / other settings.
However, one of the user got French date time setting, and below code fails format datetime and file size.
Not sure what is the best way to handle all regions? Any suggestions pls?
invalid FR format - 02-d꣭2019 15:23:10 , fileSize = 110,00 , instead
of 110.00
fileSize = FileLen(tool) / 1024
creationDate = Format(Local2GMT(.getFile(tool).DateCreated), "DD-MMM-YYYY HH:MM:SS")
modifiedDate = Format(Local2GMT(.getFile(tool).DateLastModified), "DD-MMM-YYYY HH:MM:SS")
accessfileDate = Format(Local2GMT(.getFile(tool).DateLastAccessed), "DD-MMM-YYYY HH:MM:SS")
Function Local2GMT(dtLocalDate As Date) As Date
Local2GMT = DateAdd("s", -GetLocalToGMTDifference(), dtLocalDate)
End Function

Now() is giving an error

I am getting an error in the below code.
Dim CurrentTime As Date
CurrentTime = Format(Now(), "hh:mm AM/PM")
If CurrentTime = ActiveSheet.Range("I1") Then
Call SendEMail
End If
When the time is right, then the macro is debugging and Now is highlighted.
Could anyone solve this problem?
You are not getting an actual error are you? It is just not working as expected.
Matt Cremeens has identified your issue I believe, you have declared CurrentTime as a date data type. A date data type stores a number representing a time/date, however you are asking for it to store string information (AM/PM) too which is can't so it is getting stripped out.
The results is cell one may hold a value like '10:30 AM' but the Format(Now(), "hh:mm AM/PM") code going into the Date variable is resulting in '10:30:00', so the two are never matching as strings. Copy as Matt has suggested and this should work (Dim CurrentTime As String).
Better yet, use the date comparison function DateDiff:-
If DateDiff("s",ActiveSheet.Range("I1"),Time()) > 0 then
SendEmail
End If
This is saying if the time now is greater than the value in I1 (to the second) then run SendEmail.
I don't have the environment to test the solution right now but from what I remember you don't need the brackets in 2007 and also you don't need the format.
Try the following code and see if that fits your need:
If Hour(Now) = ActiveSheet.Range("I1") Then
(...)
End If

Loop through a string in PowerBuilder

First of all, I'm a noob at PowerBuilder and can't seem to find how to do this anywhere.
I have been give the task of rewriting an application at work. My boss wants the new application to mimic the old one as much as possible, so that leads to my question. There is a date field that will allow a date input separated by a tilde (01/01/15~01/31/15) and it uses this to get a beginning date and end date for a between SQL statement.
With all that being said, I am trying to do the same thing in PowerBuilder 12.6 classic. I know that I can accomplish the same thing by using two date pickers (begin date and end date), but my boss wants this transition to be as seamless as possible to the end users.
I have a sle_date_shipped on my form that currently takes in a date format of mm/dd/yy and will process it, but I want to allow mm/dd/yy~mm/dd/yy and parse out a begin and end date. My pseudo code would look something like this:
int i
String s
String start_date
String end_date
if this.textsize > 8 then
s = this.text(value of this position in the string)
start_date = s + s
if this.text = "~" then
s = s + 1
s = this.text(value of this position in the string)
end_date = s + s
end if
this.textsize + 1
else
start_date = this.text
end if
I do realize that my pseudo code probably needs some work, I'm just trying to get the point across.
Thanks
Don't loop...
string ls_start, ls_end
ls_start = left( this.text, pos( this.text, '~' ) - 1)
ls_end = right( this.text, Len( this.text) - pos( this.text, '~'))
-Paul Horan-

Getting type mismatch error in replace function in vba

My vba code is to replace current time and date to 4_17_2014 8_09_00 PM format
But i am getting type mismatch error while running below VBA code
Function Current_Date_Time_Stamp()
Dim CurrTime As Date
CurrTime = Now
MsgBox Now
CurrTime = Replace(CurrTime, "-", "_")
MsgBox CurrTime
CurrTime = Replace(CurrTime, ":", "_")
Current_Date_Time_Stamp = CurrTime
End Function
Can anybody help me why i am getting error
As #Tim Williams mentioned in comments, Replace works only with string variables, but CurrTime is date (actually, date variables doesn't store format of date, but only date itself. Format when displaying date depends on regional settings and number format of your cell).
However you can use function with single line of code like this:
Function Current_Date_Time_Stamp()
Current_Date_Time_Stamp = Format(Now, "mm_dd_yyyy h_mm_ss AM/PM;#")
End Function

XPages date only fieldonly

Is it possible to create a date only field in XPages? I have tried the following in the querySaveDocument event but the field still ends up with a time portion of 00:00:00
var notesDoc:NotesDocument = document1.getDocument();
var dt:NotesDateTime = session.createDateTime(#Today());
dt.setAnyTime();
notesDoc.replaceItemValue("MyDateField", dt);
It is not completely clear what you are trying achieve.
You can put an EditBox component on your XPage, then go to the "Data" tab. From there you can change the formatting from String to Date. More options should appear on how to format the date in the field. It will handle passing the date to the back end document.
If it is you want to write directly to the back end document, then here is a page listing samples on working with NotesDateTime.
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/NotesDateTime_sample_JavaScript_code_for_XPages
Here is code by Sven:
ndt = session.createDateTime(ndt.getDateOnly());
item.setDateTimeValue(ndt);
error in date items, daylight Saving
Update:
I had to do the same thing and found out that it's working this way in Java agent in 8.5.2FP3:
DateTime dt = session.createDateTime(new java.util.Date());
dt.setAnyTime();
doc.appendItemValue("DT", dt);

Resources