Getting view options in Microsoft Project using VBA - vba

If I want to change the current date format to 20, for example, I can use the command
OptionsViewEx DateFormat:=20
but how can I get the current date format (or any other view option for that matter)?

DefaultDateFormat should be the function to use.
oldvalue = Application.DefaultDateFormat
Application.DefaultDateFormat = 20 ' or = pjDate_mm_dd_yyyy
This gets or sets the default date format. (technet)
This gives the complete list of format types.

If you use Date function get a date in current format, but if you need change use format(Date,"yyyy-mmmm-dd") for example.

Related

How can I fetch a dynamic file from FTP server-generated every day?

There are transactional input CSV files coming on a daily basis on an FTP location. I need to read these input files and process them on daily batch execution. The name of the files remains the same every day, but the date gets appended at the end of the filenames every day,
Ex:
Day1
General_Ledger1_2020-07-01,
General_Ledger2_2020-07-01,
General_Ledger3_2020-07-01,
General_Ledger4_2020-07-01,
General_Ledger5_2020-07-01
Day2
General_Ledger1_2020-07-02,
General_Ledger2_2020-07-02,
General_Ledger3_2020-07-02,
General_Ledger4_2020-07-02,
General_Ledger5_2020-07-02
How can I append this Date information to the input file name every time the job runs?
I have faced similar problem earlier and this can be solved using calculated parameter in the file path. Here, you can create expressions that will retrieve the file dynamically.
Example,
CONCAT( UPPER(lit('$(Prefix)')), ADD_DAYS( TODATE(lit('$(currentTime)'), 'yyyy-mm-dd'), 'yyyy-mm-dd' ,-1),'.csv')
Breaking of the expression :
$(currentTime) : this system parameter will get the current date (this will also include timestamp).
(TODATE(lit('$(currentTime)'), 'yyyy-mm-dd') : TODATE will get only date from the whole timestamp with format as ‘yyyy-mm-dd’.
ADD_DAYS(TODATE(lit('$(currentTime)'), 'yyyy-mm-dd'), 'yyyy-mm-dd' ,-1) : ADD_DAYS here will add -1 to the date retrieved from. TODATE(). Hence (2020-04-24) + (-1) would give us 2020-04-23
$(Prefix) : $(Prefix) will be an user defined input parameter of type String which user will be providing at runtime – Since the
prefix will be always dynamic.
CONCAT() : Finally to combine all the results and form the exact file path CONCAT() can be used. Also in between some static
string is added as it will always be fixed for every file to be read.

Need to parse a date range location in a field to two SQLStatements

Have a custom field that contains a date range in the following format:
3/16/20 - 2/22/20
What I need to do is separate this one line into two different fields, the first selection/range and the second range, so if you take the screenshot I need it to be separated to 3/16/20 for one field and 3/22/20 for the other field.
Currently I have this and something is causing an error randomly and I want to make sure it is not the SQL statement
For the first selection, I use the following:
TO_DATE(LTRIM(SUBSTR({custbody_shipwindow}, 1,(INSTR({custbody_shipwindow}, '-')-1))),'mm/dd/yy')
For the second selection I use the following:
TO_DATE(LTRIM(SUBSTR({custbody_shipwindow},(INSTR({custbody_shipwindow}, '-')+1), LENGTH({custbody_shipwindow}))),'mm/dd/yy')
Try:
TO_DATE(REGEXP_SUBSTR(TRIM({custbody_shipwindow}),'^[^ -]+'),'MM/DD/YY')
TO_DATE(REGEXP_SUBSTR(TRIM({custbody_shipwindow}),'[^ -]+$'),'MM/DD/YY')
or to be safe, but possibly not return the date:
TO_DATE(REGEXP_SUBSTR(TRIM({custbody_shipwindow}),'^[0-9]{1,2}/[0-9]{1,2}/[0-9]{1,2}'),'MM/DD/YY')
TO_DATE(REGEXP_SUBSTR(TRIM({custbody_shipwindow}),'[0-9]{1,2}/[0-9]{1,2}/[0-9]{1,2}$'),'MM/DD/YY')

Pentaho kettle convert date to unix

I'm trying to pacha a string format dated "2019-05-14 13:30:00" to a UNIX format.
In javascript I got it but in the javascript kettle module I am not able to return the numeric value 1557833442
the line of code is this:
const tests = (new Date ("2019-05-14 13:30:00"). getTime () / 1000);
It looks like the Date() constructor doesn't like the format you are using.
If you want the current date, use a Get System Info, it has a number of useful date options.
If you are converting an incoming field, use the Select Values step to change the metadata, using the format string that matches your string field's format.

Error Converting DateTime using format

I get the following error when trying to import a CSV file.
Error Converting '2007/01/02' to type: 'DateTime'. Using the format: 'yyyy/MM/dd'
I have set the class like this:
[FieldConverter(ConverterKind.Date, "yyyy/MM/dd")]
public DateTime PriceDate;
Any idea why that could be, since the format matches - it is the second of Jan 2007?
When I change the date format to 2007.01.02 then Filehelpers parses perfectly.
I use V 3.1.5.0
Thanks
Try changing the mask to:
[FieldConverter(ConverterKind.Date, "yyyy/M/d")]
public DateTime PriceDate;
Click on the 'Converters' tab in this link to learn more about a handful of datatypes available, such as numeric and dates.

Jqgrid Datetime format sorting issue

I have a datetime format returned from the backend(dd/MM/yyyy HH:mm:ss).
JQgrid has column values as {name:'createddate',index'createddate',sorttype:'date',formatter:'date'}
but the sorting is not working properly
the result is displayed as follows:for example
06/11/2013 01:23:33
11/09/2013 02:22:34
20/09/2013 01 22:33
but the result required is:
11/09/2013 02:22:34
20/09/2013 01:22:33
06/11/2013 01:23:33
Thanks in advance.
If you use formatter:'date' then you should specify formatoptions with srcformat and newformat options. Default format of input data (srcformat) which expect formatter:'date' is ISO8601Short: "Y-m-d". You use another format so you have to specify srcformat. Format of date which uses jqGrid is PHP format (described here). So I think that the problem will be solved by adding
formatoptions: {srcformat: "d/m/Y H:i:s", newformat: "d/m/Y H:i:s"}
More better would be to use ISO-8601 format if you returns data from the server. It's locale independent format. You can use on the server side DateTime.ToString("o") or DateTime.UtcNow.ToString("o"). In the case you can change formatoptions to
formatoptions: {srcformat: "ISO8601Long", newformat: "d/m/Y H:i:s"}