How do i append today's date after the file name in Automation Anywhere? - automationanywhere

I am trying to rename a file in the format like-
"FileName" $date$ ".xlsx"
However, the filename is saved with random numbers like, 24.xlsx.
I have tried changing the date format from the variables manager screen and set it to mm/dd/yyyy, but still no luck.
Any assist on this ?
The code in automation anywhere looks something like this:
Rename Files C\Users\<username>\Documents\query.xlsx to "FileName $Date$ .xlsx"
enter image description here
enter image description here
Expected result be something like : Filename 09152019.xlsx
Actual Result : 24.xlsx

Filename can't have / or :
To rename the file as mentioned in the post use $Month$$Day$$Year$ if day or month less than 10, for example, 09/15/2019 it will be 9152019.
So, to make it two numbers based you will need to use if condition to check the day and month values separately if less than 10 you will do variable operation to add 0 to the left.

Related

Converting DT_WSTR to DT_DATE

So Im pretty new to this stuff but working through a few issues. What I am trying to do is pull source files from a Flat File Source but the dates in all my source files are formatted to YYYYMMDD so I have inserted a Derived Column task and created an expression to format all the columns with dates YYYYMMDD to YYYY-MM-DD and that looks like this:
LEFT(ISSUE_DT,4) + "-" + SUBSTRING(ISSUE_DT,5,2) + "-" + RIGHT(ISSUE_DT,2)
All is good with that except it's in the data type of DT_WSTR so I dropped in a Columns Conversion task to convert DT_WSTR to DT_DATE but I keep getting the following error:
[Columns Conversion [1]] Error: Data conversion failed while converting
column "ISSUE_DT Formatted" (258) to column "Copy of ISSUE_DT Formatted"
(16). The conversion returned status value 2 and status text "The value
could not be converted because of a potential loss of data.".
I have tried opening the advanced editor and navigated to the Data Conversion Output Columns and tried changing the DataType under Data Type Properties to DT_DATE but still the same error..
What am I missing or doing wrong??
Data Flow
Formatted Dates
Column Conversion
Column Conversion Advanced Editor
You have some dates that are not in the format that your SSIS package is expecting. Perhaps single-digit months or days do not have a leading 0. That scenario would definitely cause this specific error.
Take today for example, if single-digit months or days did not have leading zeroes, you have 2018918 instead of 20180918. Without seeing the data, I can't guarantee that this is the exact issue, but it is something like this. The error is occurring when converting the string to the date. So continuing with the example above, after your Derived Column ISSUED_DT formatted would have a value of '2018-91-18' which of course is not a valid date and causes the error.

SPSS - pass values of three dates fields into file name

My dataset has three date fields (adate10): Period, Version, and Created. The values for each field are identical for all cases. Let's say the values are:
Period = 10/01/17
Version = 11/15/17
Created = 11/25/17
I would like to pass all three dates into a SAVE OUTFILE='C:\Users\Inventory ? ? ?... command so the file name is:
C:\MyData\Inventory p20171001 v20171115 c20171125.sav
How I can pass the values of these three date fields into the save command? I assume Python is the way to go, but cannot figure out the syntax. I see several solutions at the link below, but they all involve only one date field; I have three. (And even when I tried with one date I couldn't get any of them to work).
http://spssx-discussion.1045642.n5.nabble.com/include-value-from-variable-in-filename-when-saving-td4326879.html
Here you go with a little Python:
BEGIN PROGRAM.
import spss, spssdata
# names of date variables (case sensitive)
varlist = ['period', 'version', 'created']
# fetch dates from dataset and format them to YYYYMMDD
data = spssdata.Spssdata(indexes=(varlist), cvtDates=(varlist))
dates = [date.strftime("%Y%m%d") for date in data.fetchone()]
data.close()
# Create 'save command' command and submit it to spss
spss.Submit(r"""
SAVE OUTFILE = 'C:\MyData\Inventory p{0} v{1} c{2}.sav'.
""".format(*dates))
END PROGRAM.
You can get the results you need with syntax only:
TEMPORARY.
select if $casenum=1.
format Period Version Created (f11).
write out="C:\MyData\save with dates in name.sps"
/"save out='C:\MyData\Inventory p", Period, " v", Version, " c", Created, ".sav' ".
exe.
insert file="C:\MyData\save with dates in name.sps".

Change date format in order to find difference in Time in Neo4j 3.2.5

I am working on a code in Neo4j and want to find out the difference between two time columns. The date time is in format 20130508 19:14:56.913.
I also tried using APOC function, but I am getting the error that it is Unknown function. Could anyone please help me this.
I think you can use the APOC function apoc.date.parse. The function signature is:
apoc.date.parse(date, targetTimeUnit, format)
date should be a string representing the date you are converting to the specified targetTimeUnit (ms for target milliseconds, in the example). The date should be in the specified format, indicated by the third parameter.
Take a look in this example:
WITH apoc.date.parse('20130508 19:14:56.913','ms','yyyyMMdd HH:mm:ss.ms') AS initialTime,
apoc.date.parse('20130508 20:14:56.913','ms','yyyyMMdd HH:mm:ss.ms') AS finalTime
RETURN finalTime - initialTime as difference
The output will be:
╒════════════╕
│"difference"│
╞════════════╡
│3600000 │
└────────────┘
That is: a difference of 3600000 milliseconds between the two dates.

Regional setting confusion regarding date format from PostgreSQL

I'm working on an application that requires the following regional settings (Delphi 7 and PostgreSQL 9.0):
1. DateSeparator:='/';
2. TimeSeparator:=':';
3. ThousandSeparator:=',';
4. DecimalSeparator:='.';
5. ShortDateFormat:='MM/dd/yy';
6. ShortTimeFormat:='hh:mm:ss';
I need to change the regional setting only for my application and not system wide.
In OnCreate of the form I set the above separators, and
my current system separators are:
1. DateSeparator='|';
2. TimeSeparator='|';
3. ThousandSeparator='|';
4. DecimalSeparator='|';
(This is for the test purpose.)
Now in Postgres I have a table from where I get dates to display in my application but somehow the dateseparator doesn't seem to work (as seen in label1)!
Check the image.
I fire a query to get the dates from the table
Label1.Caption:=(Fields(1).Text);
Label2.Caption:=datetostr(Fields(1).Data) ;
The query is
select min(dat), max(dat) from diary where survey in (2008401) and event not in ('E','C','R') and region=6100;
now the same date if I take as .data differ in the date separator from .text dateseparator
why this is happening?
Why are the regional settings not applied to label1.caption (as shown in the image)?
DateToStr uses ShortDateFormat as the output format. You didn't change that from the MM/dd/yy set initially; you only changed the DateSeparator.
I'm confused though, about why you'd want to use (Fields(1).Text) (is that right? Parentheses instead of [] for the Fields subscript?).
If the DB is configured to use | as the date separator, as it appears it is from your screen image, why are you using DateToStr? It appears that .Text is getting the information in the format you're looking to obtain.
ok i found on one site
enter link description here
for getting the appropriate format all i had to do was get the fire the query as
select to_char(min(dat),'mm/dd/yy'), to_char(min(dat),'mm/dd/yy')
from diary
where survey in (2008401) and
event not in ('E','C','R') and region=6100;
This gave me the proper result in the format i wanted

I'm getting "Invalid month in date" trying to run this?

I'm trying to run the following db command against Informix:
delete from table1
where u_id in (select u_id
from table2
where c_id in (select c_id
from ptable
where name = 'Smith'
and dob = '29-08-1946'));
I pass this in as a string to the db.ExecuteNonQuery method in the MS Data Application block and I get the above error?
To get the date format '29-08-1946' to work, you need your DBDATE environment variable set to a value such as "DMY4-" (or "DMY4/"). These are standard variations for the UK (I used them for years; I now use "Y4MD-" exclusively, which matches both ISO 8601:2004 (Date formats) and ISO 9075 (SQL), except when debugging someone else's environment). There are other environment variables that can affect date formatting - quite a lot of them, in fact - but DBDATE takes priority over the others, so it is the big sledgehammer that fixes the problem.
One of the problems is that your notation using a plain string is not portable between US and UK (and ISO) settings of DBDATE. If you have a choice, the neutral constructor for dates is the MDY() function:
WHERE dob = MDY(8,29,1946)
This works regardless of the setting of DBDATE. You can probably use TO_DATE() too:
SELECT TO_DATE('29-08-1946', '%d-%m-%Y') FROM dual;
This generated '1946-08-29 00:00:00.00000' for me - the function generates a DATETIME YEAR TO FRACTION(5) value, but those convert reliably to DATE values in Informix.
You can also use the DATE() function or an explicit cast to DATE (either CAST('29-08-1946' AS DATE) or '29-08-1946'::DATE), but both of those are subject to the whims of the locale of the users.
Your date field is improperly formatted. Since there is no 29th month in the year 1946 that is what is causing the error.
I'd try just swapping the month and day. 08-29-1946.
The way the day and month parts of a date string are read in can depend on your computer's culture settings.
It is always safer to pass date strings to a database in the form 'dd-MMM-yyyy' (i.e. '29-aug-1946')
It's even safer to pass them as YYYY-MM-DD, the dd-MMM-yyyy in that example will fail on a server with a (for example) French locale.

Resources