How do you convert a date in XSLT2.0? - xslt-2.0

How can I format the resulted date below to display like this: MM/dd/YYYY (e.g.: 05/04/2020)?
The $getField will be: 2020-05-04T15:00:12
My value in the template is:
<xsl:value-of select="xs:dateTime($getField)+xs:dayTimeDuration('PT1H')"/>
Currently, it displays as follows: 2020-04-05T16:00:12
Each time I try using format-date, I get an error.
Also, if I will use xs:date(xs:dateTime($getField)+xs:dayTimeDuration('PT12H')), it will display only the date, without hours/minutes, but still not sure how can I change the order for date?
Thanks!

Use the format-dateTime() function with the desired picture "[M01]/[D01]/[Y0001]":
format-dateTime(xs:dateTime($getField)+xs:dayTimeDuration('PT1H'), "[M01]/[D01]/[Y0001]")

Related

format timezone using XSLT/xpath 2.0

I need to get one date in one format like this:
2020-06-03T06:14:00.000+0100.
following this documentation page [1], I tried to do with this expression, but always get an error:
format-dateTime(current-dateTime(), "[Y0001]-[M01]-[D01]-[H01]:[m01]:[s][Z0000]")
I tried to put with this mask too:
format-dateTime(current-dateTime(), "[Y0001]-[M01]-[D01]-[H01]:[m01]:[s][Z0001]")
but the result is 2020-06-03-14:39:50+02:00
I need to delete the ":" on the offset, ¿Which mask may I use?
[1]https://www.rfc-editor.org/rfc/rfc3339#section-5.6
A workaround for your problem could be splitting the output of format-dateTime into two parts and remove the colon on the second expression:
concat(format-dateTime(current-dateTime(), "[Y0001]-[M01]-[D01]-[H01]:[m01]:[s]"),translate(format-dateTime(current-dateTime(), "[Z0001]"),":",""))
Maybe this works for you.

Angular 6 Date Pipe not showing anything on iPhone safari browser

I'm using simple date pipe to format date which is working fine on web and android browsers but on IOS it's showing nothing. If I remove the PIPE and display data then it's shown but not with the PIPE.
{{race.race_date | date:'M/d/y'}}
You can check this issue on Issue link
Backend is returning data correctly.
UPDATE:
ah yes, the issue is with ios device only, you need to either use a custom pipe or convert the date to a date object. you can use moment but heres a custom pipe
<span>{{race.race_date | dateTimeFormatFilter : "MMM DD, YYYY"}}</span>
#Pipe({name: "dateTimeFormatFilter"})
#Injectable()
export class DateTimeFormatPipe implements PipeTransform {
transform(date: any, format: string): any {
if (date) {
return moment(date).format(format);
}
}
}
I ran into the same issue. I don't know how much local settings affect it, but here's what I have found.
The correct date format that works for me looks like this:
"2021-11-25T09:08:28"
I had problem with format "2021-11-25 09:08:28" so all I did is replace space with a 'T'.
In angular it looks like this:
{{ "2021-11-25 09:08:28".replace(' ', 'T') | date: 'dd.MM.' }}
As far as I know the date format after pipe, in my case 'dd.MM.', doesn't have affect on the problem. This format type also works in Chrome.

Rails string to DOB year

I'm currently storing strings formatted like "01/01/1989" (client side validation) for the bday field.
I want to parse out the year and store it as a variable, like this:
#bdayyear = current_user.bday.year
I want that to bring back "1989"
How would I go about doing that?
Just do using #strftime and ::strptime :
s = "01/01/1989"
current_user.bday.strptime(s, "%d/%m/%Y").strftime("%Y")
# => "1989"
Convert it into a DateTime object and you can call year on it
>> DateTime.parse("01/01/1989").year
=> 1989
If the format is always consistent the why not just use the string
"01/01/1989".slice(-4..-1)
"01/01/1989"[-4..-1]
Or
"01/01/1989".split(/\W/).pop
These will all return "1989" without converting it to a date

af:inputDate is returning GMT instead of user selected date in ADF

I am using af:inputDate tag to capture the date in adf.
My web page looks like -
The date gets stored at startDate (which is java.util.Date).
Now after
DataObjectEncodingUtils.encodeDate(startDate)
it is returning 2014-02-01 18:30:00 which is exactly 5.30 hours behind the selected date.
Here is the entry details in my trinidad-config.xml -
<?xml version="1.0" encoding="windows-1252"?>
<trinidad-config xmlns="http://myfaces.apache.org/trinidad/config">
<skin-family>mySkin</skin-family>
<formatting-locale>en_GB</formatting-locale>
<time-zone>Asia/Calcutta</time-zone>
<!--<time-zone>IST</time-zone>-->
</trinidad-config>
Am i missing something ?
-Amit
Have you tried using an component together with the inputDate?
You can set the date format and the timezone in which you want the date displayed.

Delphi & Absolute database : Delete Query

Why is it that my query does not work ?
Form1.ABSQuery1.Close;
Form1.ABSQuery1.SQL.Clear;
Form1.ABSQuery1.SQL.Text:='DELETE FROM LOG WHERE status = ''YES'' and DATE BETWEEN :d1 and :d2';
Form1.ABSQuery1.Params.ParamByName('d1').Value :=cxDateEdit1.Date;
Form1.ABSQuery1.Params.ParamByName('d2').Value :=cxDateEdit2.Date;
Form1.ABSQuery1.ExecSQL;
Form1.ABSTable1.Refresh;
I get this error :
You should be using AsDateTime in your Params setting code.
Form1.ABSQuery1.SQL.Text:='DELETE FROM LOG WHERE status = ''YES'' and DATE BETWEEN :d1 and :d2';
Form1.ABSQuery1.Params.ParamByName('d1').AsDateTime :=cxDateEdit1.Date;
Form1.ABSQuery1.Params.ParamByName('d2').AsDateTime :=cxDateEdit2.Date;
Form1.ABSQuery1.ExecSQL;
Using Value converts the cxDateEdit1.Date to a generic string format for assignment, and that doesn't properly convert it to the YYYY-MM-DD format that most databases (including ABS) expect. Properly using AsDateTime allows the database driver/component to convert to the specific date format the DBMS uses.
Also, is your database field really named DATE? Date is usually a reserved word or function name in most DBMS, and if it is it usually needs to be quoted.
Form1.ABSQuery1.Params.ParamByName('d1').DataType := ftDateTime;
Form1.ABSQuery1.Params.ParamByName('d1').Value :=cxDateEdit1.Date;
You must explicitly specify the data type of the parameter to it had no such problem, and then convert to a string does not need to

Resources