XML Publisher Parameter Date Formatting - bi-publisher

In XML Publisher template, how can I format the date parameter to DD-Mon-YYYY format?
<?param#begin: p_start_date?>
Start Date - <?xdofx:substr($p_start_date,1,4) || '-' || substr($p_start_date, 6,2) || '-' || substr($p_start_date, 9,2)?>
With the above format, my output is 2017-09-18, expected output is
18-May-2017
I have even tried with <? xdofx:p_start_date('DD-Mon-YYYY’)?>, but the output is
2017-09-18

Did you try using the to_date function ? Its documented here.

Related

Add line break to generated CST node

I am modifying a CST tree in order to add information in it like this
(EvoQuery) `<Status s> <QlQuery q>`;
But I'd like to have a line break between the Status and the QLQuery. When I try this :
(EvoQuery) `<Status s> \n <QlQuery q>`;
Rascal marks a syntax error. What is the proper way to format a CST node ?
The way to introduce newlines in concrete syntax is by writing it literally, just like in string template syntax:
(EvoQuery) `<Status s>
' <QlQuery q>`;
Compare to the string template syntax:
str x = "<s>
' <q>";

How to get local time as a formatted string in Lua

I need a date time string formatted as %Y-%m-%d %H:%M:%S.
I can't figure out how to use Lua's standard functions os.date() and os.time() to achieve that.
os.date is the function you are looking for. Its first optional parameter, format, does what you want:
os.date('%Y-%m-%d %H:%M:%S')
--> 2019-04-02 10:50:52
From the Lua 5.3 manual on os.date:
os.date ([format [, time]])
Returns a string or a table containing date and time, formatted according to the given string format.
If format starts with '!', then the date is formatted in Coordinated Universal Time.
If format is not "*t", then date returns the date as a string, formatted according to the same rules as the ISO C function strftime.
You can learn more about the formatting rules of C's strftime here.
In case you don't get your local time for whatever reason you can simply add the required offset.
local timeShift = 3 * 60 * 60 -- +3 hours
os.date('%Y-%m-%d %H:%M:%S', os.time() + timeShift)
--> 2019-04-02 18:24:15 for 15:24:15 UTC
I use lib https://github.com/Tieske/date. Get localtime -
date(true):addminutes("your offset"):fmt('%Y-%m-%d %H:%M:%S'),

Add days to date in SAP HANA stored procedure

I need to add days to date in HANA stored procedure, but I am getting error message
ERROR WHILE parsing DATE/ TIME
I use this statement where p_end_date is parameter of my stored procedure.
v_end_date_plus := add_days (TO_DATE(' || p_end_date || ' , 'YYYY-MM-DD' ), 90)
Is there is any other way or what I am doing wrong in it ?
Even though you didn't post what error you receive, I guess that the problem in your code is the way you referenced your input variable.
v_end_date_plus := add_days ( :p_end_date , 90);
With the colon (:) in front of the parameter you should be able to use it without having to cast it into a different data type.
#LarsBr. is correct that you need a colon (:) to reference the variable, and that if it is really a DATE type, you don't need to convert TO_DATE again.
But additionally, in your example you have some mixup with quotes and concatenation that makes me think that you actually want to construct some character string using p_end_date. This would need conversion to a date first:
p_end_date := '2016-05-03'; -- for example
v_end_date_plus := add_days(TO_DATE( :p_end_date , 'YYYY-MM-DD' ), 90);
The part ' || p_end_date || ' in your example also looks a bit like the whole code was actually part of string to be used in EXEC or similar. If that's the case, you need to have escaped single-quotes for both parameters, e.g.
exec 'v_end_date_plus := add_days(TO_DATE(''' || :p_end_date || ''', ''YYYY-MM-DD'' ), 90)';
p_end_date should be a varchar field, or the appropriate string literal used in your technology. It should not be enclosed in quotes.
v_end_date_plus := add_days (TO_DATE(p_end_date , 'YYYY-MM-DD' ), 90)
EXPLANATION USING ORACLE AS REFERENCE :
In Oracle database, the default date format is dd-MON-RR or dd-MON-YYYY.
So, if I use correct date format to p_end_date variable, I am able obtain output.
However, if I diverge from this default format,my attempt would error out.
So, if I want the flexibility to redefine p_end_date in format of my choice, and not as per default settings, it should be a String literal.(varchar in Oracle ).
EDIT:
The essence of this answer was just to suggest that the variable should be passed as a varchar. Borrowing from Lars Br's suggestion below to modify the p_end_date variable's syntax:
v_end_date_plus := add_days (TO_DATE(:p_end_date , 'YYYY-MM-DD' ), 90)

GWT DateTimeFormat.parse always Illegal Argument Exception

Doesn't meter what string I pass to parse I'm always getting Illegal Argument exception on GWT DateTimeFormat.parse method.
For instance, what is wrong on the following code line:?
Date date = DateTimeFormat.getFormat("MM-dd-YYYY").parse("10-10-2012");
I get:
java.lang.IllegalArgumentException: 10-10-2012
at com.google.gwt.i18n.shared.DateTimeFormat.parse
Instead of YYYY for the year in the format, you should use yyyy. The format you are specifiying would match a date that looks like: 10-10-YYYY (since Y isn't a special date format character).

Ruby/Rails - DateTime parsing

I'm trying to return a date as a string but remove the first 0 from the hour returned.
This is the code I'm using:
t = Time.new
current_date = Time.local(t.year, t.month, t.day, t.hour, t.min/30*30)
time_str = current_date.strftime("%I.%M+%p").downcase
puts time_str
Outputs:
03.00+pm
Expected output:
3.00+pm # need to remove the last zero from the hour(s)
just use %l instead of %I
.strftime("%l.%M+%p")
Just add one point: if you want to quickly find the format string, man date will give you the correct answer if you are on OS X or Linux.
If the strftime and date format string differs, you can always find it up in the Ruby document, here's the document for strftime.

Resources