controlM variable for YYYYMM? - control-m

I'm using ControlM and in a command, I would like to find a variable that gives me the date in this format : YYYYMM
I found there is %%$DATE variable but it gives YYYYMMDD
Thanks for you help

It is possible to define and concatenate a variable that will represent the date in such a format.
These are available:
Day DD, %%DAY,
Month MM, %%MONTH,
Year YY, %%YEAR,
Year YYYY, %%$YEAR

Prefer %%$OYEAR AND %%OMONTH over %%$YEAR and %%MONTH
I suggest using the variables %%$OYEAR and %%OMONTH over %%$YEAR and %%MONTH. The reason is that date variables beginning with O refer to processing dates and do not necessarily coincide with the system date. For this case you could use any of the following options:
1. YYYYMM = %%$OYEAR.%%OMONTH
2. YYYYMM = %%SUBSTRING %%$ODATE 1 6
The $ symbol preceding the variable %%$OYEAR or %%$ODATE indicates that the year is returned in 4-digit format, instead of OYEAR or ODATE which print the year with only 2 digits.
The dot (.) character is used for concatenate variables.
For example: For the order day May 29, 2020.
1. %%$ODATE would print 20200529
2. %%ODATE would print 200529

Related

Formatting year month variable as date

In Stata I have a variable yearmonth which is formatted as 201201, 201202 etc. for the years 2012 - 2019, monthly with no gaps. When I format the variable as
format yearmonth %tm
The results look like: 2.0e+05 for all periods, with the exact same number each time. A Dickey-Fuller test tells me I have gaps in my data (I don't) and a tsfill command generates dozens of empty observations between each period.
How do I properly format my yearmonth variable so I can set it as a monthly date?
You do have gaps — between 201212 and 201301, for example. Consider a statement like
gen wanted = ym(floor(yearmonth/100), mod(yearmonth, 100))
which parses your integers like 201201 into year and month components. So floor(201201/100) is floor(2012.01) and so 2012 while mod(201201, 100) is 1. The two components are then the arguments of ym() which expects a year and a month argument.
Then and only then will your format statement do you want. That command won’t create date variables.
See help datetime in Stata for more information and Problem with displaying reformatted string into a four-digit year in Stata 17 for an explanation of the difference between a date value and a date display format.

Convert string of length 8 to *EUR date for comparing

I want to convert a string of length 8 to a date type for comparing it. The string is formatted as DDMMYYYY (*EUR).
It has no periods for seperating the days from months and months from years. If I input a value like '01012018' to the %date BIF the compiler tells me that the expression is too short for the format *EUR:
D dateEUR s d datfmt(*EUR)
C eval dateEUR = %date('01012018':*EUR)
My previous way to compare to two dates was to take both of them, store them in datastructues, reorder the date with subfields and take the resulting, reordered date from a overlaying subfield.
Has anyone a idea of how to convert the 8A string to a DATE type in RPGLE?
The format you specify will depend on whether or not you store the date separators. If your date is in a 10-byte character field as DD-MM-YYYY (with the dashes), this is again EUR format:
%date(alpha_date : *eur)
If you don'tt need standard separators with your date (DDMMYYYY in an 8-byte character field) simply append the number zero (0) to the end of the format name:
%date(alpha_date : *eur0)

Converting characters to dates

In R, it seems like this should be obvious, but I'm having trouble. I have dates formatted as 1/1/00, 12/31/00, etc., where each part is abbreviated.
When I try to convert it to a date, I get this error:
> headlines$Date <- as.Date(headlines$Date)
Error in charToDate(x) :
character string is not in a standard unambiguous format
I've also tried the below, but get all NAs:
> headlines$Date <- as.Date(headlines$Date,format="%b/%d/%y")
How should I convert this column to dates?
You were on the right track by adding the format argument. I'm guessing you realized that the first error ("character string is not in a standard unambiguous format") happened because R doesn't know which of the numbers is the day, month, or the year. Say one of the values was "01/02/03"; there's no way of knowing whether it's 2 January 2003, or 1 February 2003, and so on.
In this case I think you just need to fix what you're passing to the format argument. %b is the symbol for abbreviated month in text form, not number form (e.g. "Jan" instead of "01"). You need to use %m instead for months stored as numbers. Try this:
headlines$Date <- as.Date(headlines$Date,format="%m/%d/%y")
See this page for more info about date formats in R.
Replace format = "%b/%d/%y" with format = "%m/%d/%y".
%b means month as in Jan, Feb, Mar and so on.
%m is the integer equivalent (1, 2, 3 etc).
Further reading: https://www.stat.berkeley.edu/~s133/dates.html

Convert YYYY-YY to Year(date)

I have a data frame with year column as financial year
Year
2001-02
2002-03
2003-04
How can I convert this to as.Date keeping either the whole thing or just the second year i.e 2002,2003,2004. On converting with %Y, I inevitably get 2001-08-08, 2002-08-08, 2003-08-08 etc.
Thanks
library(lubridate)
Year <- c('2001-02', '2002-03', '2003-04')
year(as.Date(gsub('[0-9]{2}-', '', Year), format = '%Y'))
1) ISOdate Clarifying the question, since it refers to yearend and Date we assume that the input is the fiscal Year shown in the question (plus we have added the "1999-00" edge case) as well as the month and day of the yearend. We assume that the output desired is the yearend as a Date object. (If that is not the intended question and you just want the fiscal yearend year as a number then see Note at the end.)
Returning to the assumed problem let us suppose, for example, that March 31st is the yearend. Below we extract the first 4 character of Year using substring, convert that to numeric and add 1. Then we pass that along with month and day to ISODate and finally convert that to Date. No regular expressions or packages are used.
# test inputs
month <- 3
day <- 31
Year <- c("1999-00", "2001-02", "2002-03", "2003-04")
# yearends
as.Date(ISOdate( as.numeric(substring(Year, 1, 4))+1, month, day))
## [1] "2000-03-31" "2002-03-31" "2003-03-31" "2004-03-31"
2) string manipulation An alternative solution using the same inputs is the following. It is similar except that we use sub with a regular expression that matches the minus and following two characters subtituting a zero length string for them, converts to numeric and adds 1. Then it formats a string in a format acceptable to as.Date by using sprintf and finally applies as.Date. No packages are used.
as.Date(sprintf("%d-%d-%d", as.numeric(sub("-..", "", Year))+1, month, day))
## [1] "2000-03-31" "2002-03-31" "2003-03-31" "2004-03-31"
Note: If you only wanted the fiscal yearend year as a number then it would be just this:
as.numeric(substring(Year, 1, 4)) + 1

Change database value based on date (ASP)

I have 3 dropdown lists in a form for the user to input the date by day, month and year. How can I make that once t is the date that been input by the user, it will change the status from PUBLISH to UNPUBLISHED in the database?
Below is my codes:
Need your help. Thanks.
Why don't you use the DateSerial function to convert the separate values into date values, and use that to compare two dates.
From the page at W3Schools:
The DateSerial function returns a Variant of subtype Date for a specified year, month, and day.
Syntax
DateSerial(year,month,day)
Parameter Description
year Required. A number between 100 and 9999, or a numeric expression. Values between 0 and 99 are interpreted as the years 1900–1999. For all other year arguments, use a complete four-digit year
month Required. Any numeric expression
day Required. Any numeric expression
Examples
Example 1
document.write(DateSerial(2010,2,3))
The output of the code above will be:
2/3/2010
Example 2
Subtract 10 days:
document.write(DateSerial(2010,2,3-10))
The output of the code above will be:
1/24/2010

Resources