Webfocus - HGETC vs. hard-coded date - webfocus

I have this line of code:
TDY_DATE/HMDYYs = HGETC(8,'HMDYYs');
Its used to generate a report based on today's date.
How can I revise this line so I can hard-code a date other than today?
Thanks.

simply use a FPRINT to assign hardcoded date to your variable
-SET TDY_DATE = FPRINT(HARDCODED_DATE, 'HMDYYs', 'A8');

Related

change date format on print page using window.print - javascript

there is any way to do it?
I know user can change this in his settings, but there is any way to change this in code?
thanks
You can use the JS Date type - Check out: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date
It can convert any date string to a specific locale. Or you can use its methods to build your own output.
Date d = new Date(dateString); //your current date as string
console.log(d.toLocaleDateString('en-US')); //for example US locale

Javascript to add future dates to embedded data in Qualtrics

I'm being asked to integrate JavaScript into Qualtrics to accomplish the following three steps:
Get the current date in UTC format and convert to ISO 8601.
Use the current date in the prior step to create a future date (i.e., 3 months from now).
Assign the value of the date generated in #2 to an embedded data field.
Note: This isn't in my wheelhouse and I'm having quite a bit of trouble accomplishing this task.
Here's a snippet of code that I've generated thus far:
//add 3 months from current date;
var someDateM3 = new Date();
var numberOfDaysToAdd = 90;
someDateM3.setDate(someDateM3.getDate() + numberOfDaysToAdd);
var month3 = someDateM3.toISOString();
//assign value of month3 to embedded data field 'month3';
Qualtrics.SurveyEngine.addEmbeddedData( 'month3', "${e://Field/month3}");
Am I on the right track? I lack the training and skillset required to complete this seemingly straightforward task. Any advice would be incredibly helpful.
I think your date calculation is fine. The problem is with saving it to an embedded data variable. That should be:
Qualtrics.SurveyEngine.setEmbeddedData('month3', month3);
You need to define the embedded data variable month3 in the survey flow prior to the block that contains the question with your date calculation JavaScript.
Late to the party, but you don't actually need javascript to accomplish any of this, if you did not want to.
You can directly pipe date into an embedded data variable. You can custom format how you want that date to appear using PHP Date Syntax. You can then set relative dates again using PHP Syntax for relative datetime and using "OtherDate" Instead of "CurrentDate" when in the embedded data. Just make sure to encode the syntax for both like you would a url (%20 for space, etc).
I believe it should look something like this (replace my Y-m-d with whatever formatting you'd need if that's not it):
${date://OtherDate/Y-m-d/%2B3%20month} (or /%2B90%20day instead if you want to mimic exactly what your code is doing).

Bootstrap datepicker setStartDate not working properly?

I am using Bootstrap datepicker and on selecting different values from a list its startdate is changing. It is working fine if I set the startdate 2013 from 2008 but it doesn't work if a select start date 2008 and currently its 2013.
What could be the reason here?
$('#datepicker').datepicker('setStartDate', updatedDate);
This line I am executing whenever I select different startDate.
Really need to know what updatedDate value is.
However, if you read the docs for the dtepicker the value passed in must be a string that is understandable by format
https://bootstrap-datepicker.readthedocs.io/en/latest/methods.html#setstartdate
https://bootstrap-datepicker.readthedocs.io/en/latest/options.html#startdate
Date or String. Default: Beginning of time
The earliest date that may be selected; all earlier dates will be
disabled.
Date should be in local timezone. String must be parsable with format.
So what you pass in as the format option must match the format of your start date. If you do not set the format optin, the default is "mm/dd/yyyy"
Without seeing code, I can only hypothesize; try calling [...].datepicker('update', 'date_string'); on the object to force an update on the control.

pentaho mysql datetime javascript comparison

Hi Guys!
I am having an issue, while comparing MySQL date time with format using javascript,
for an example: 2016-01-25 01:22:00
i load it and trying to compare it with in the JavaScript scope, but its not working, am using "Modified Java Script Value" with in the Pentaho Data Integration aka kettle
Its not working and showing errors, that invalid date, can anyone time me what is the correct format with in JavaScript and what format is needed when comparing date time in the JavaScript scope? Do i need to change the format?
Okay i found that you just need to replace "-" with "/" :)
Example:
NOTE: below code is from Modified Java Script Value with in Pentaho Data Integration.
Should be forward slashes, otherwise its not being accepted by the DATE constructor, says invalid date :(, i was trying to compare hard coded dates with the MySQL time stamp.
var d1 = new Date("2015/08/17 21:31:06");
var d2 = new Date("2015/08/17 21:31:07");
Alert(d1.getTime() < d2.getTime());
Interesting thing i have found is that, it can be compared with a time stamp from MySQL using HYPHENS between year-month-date, but to achieve that you have to first use select step in kettle and change the type of the field to DATE and use the format like "yyyy-MM-dd HH:mm:ss"
You can use your own formats, i was querying MAGENTO table, so i used this format
Still if there is anything more professional in terms of accomplishing this task, do share...

javascript date varies across timezone

var dt_now = '2-22-2013';//mm-dd-yyyy, this is dynamic in actual code
dt_now = dt_now.split("-");
dt_now = addZero(dt_now[2])+'-'+addZero(dt_now[0])+'-'+addZero(dt_now[1]);
dt_now = new Date(dt_now);
I am using the above code to convert a user defined text to actual date for use in rest of my code. it seems to work ok for me but on another system which is situated in a different timezone(my time -12 hours), the date comes out as February 21st instead of Feb 22nd, that is, it is running one day behind the expected date. I have no idea how to fix this or what the error might be. Any suggestions?
To avoid timezone issues, use UTC. You don't have to rely on a library; simple ISO 8601 date strings would be sufficient. See Date.prototype.toISOString for making one from a Date (compatibility).
Constructing is as simple as new Date('yyyy-mm-ddT00:00Z'), so you just need a minor change to your code to create a Date
var dt_now = '2-22-2013';//mm-dd-yyyy, this is dynamic in actual code
dt_now = dt_now.split("-");
dt_now = addZero(dt_now[2])+'-'+addZero(dt_now[0])+'-'+addZero(dt_now[1])+'T00:00Z';
dt_now = new Date(dt_now);
The Z indicates UTC. I include a time (T00:00) so it matches that which would be generated by toISOString.
In the method that outputs the date you need to use getUTC* instead of get*, i.e. getUTCDate(). To generate a date object with UTC info refer to the second answer in How do you convert a JavaScript date to UTC?

Resources