Displaying current datetime value in xsl - datetime

We are trying to display the current datetime value in XSL report along with the meridian and the timezone. I am able to achieve the same using the below tag except for the meridian. Please advice.
date:format-date(date:date-time(), 'dd/MM/yyyy hh:mm:ss Z')
Tried below, but the tt is for Microsoft date format and it is coming the same in the report and I m not able to get the expected AM or PM
date:format-date(date:date-time(), 'dd/MM/yyyy hh:mm:ss tt Z')

Since you are obviously not using XSLT 2.0, but some sort of an extension to XSLT 1.0 (perhaps EXSLT?), try:
date:format-date(date:date-time(), 'dd/MM/yyyy hh:mm:ss a Z')

If you are using XSLT 2.0, try
dd/MM/yyyy hh:mm:ssP Z
Full doc can be found here

Looks like EXSLT to me as well, in which case Michael is correct with the suggestion to use "a" to get AM/PM. If your declaration of the "date" namespace is:
xmlns:date="http://exslt.org/dates-and-times"
then that's what you're using. Implementations of EXSLT dates-and-times are supposed to support the Java JDK 1.1 SimpleDateFormat, so you can use this page as a reference. You will probably also want to refer to the exslt.org page.

Related

How to get current date in pega, YY-mm-dd format

I want to get current system date in pega (Year-Month-Date)
YYYY-mm-dd
format.
Using
#(Pega-RULES:DateTime).getCurrentDateStamp()
can get current system date in YYYY-mm-dd(Year-Month-Date) format.
The below, assigned to a Text property, gives date in format yyyyMMdd:
#(Pega-RULES:DateTime).getCurrentDateStamp()
Adjusting solution given here as below, would give the desired format yyyy-MM-dd:
#FormatDateTime(#CurrentDateTime(),"yyyy-MM-dd","America/NewYork","en_US")
Tested on Pega Personal Edition 8.6.0 using Operator with Default locale "en_US" and Time zone America/New_York.
Use this function
#FormatDateTime(#CurrentDateTime(),"MM/dd/yyyy","America/NewYork","en_US")

How to obtain string date from xml and convert in a correct format in ax?

I am trying to obtain a date from an XML file that is in this format:
2016-10-27
however, the field I am trying to put it in is in this format:
mm/dd/yyyy
is there a code for this in dynamics ax 2012? I tried str2date but it doesn't output anything.
SOLVED: Just to let you guys know even though you are obtaining a string that has a format like mine 2016-10-27 AX automatically formats it to the default format to 10/27/2016 just input the sequence correctly. (THIS IS NOT PART OF THE ANSWER I AM JUST EXPLAINING MY FINDINGS)
You will need to use str2date(string _date, int _sequence). Specify the related format in sequence. Your desired format will be 213

Format hours, minutes and seconds with moment.js

I get this value from my backend service: 171054. It represents hh:mm:ss. But when I use the formatting options from the docs it gives me back 00:00:00.
Things I've tried:
moment('171054').format('hh-mm-ss')
moment('171054').format('HH-mm-ss')
moment('171054').format('HH-MM-SS')
You are confusing format option with parsing option. Since your input string is not in ISO 8601 format, you have to specify format when parsing.
Here a working example for your use case:
var mom = moment('171054', 'HHmmss');
console.log(mom.format());
console.log(mom.format('HH:mm:ss'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment.min.js"></script>
I am not sure if momentjs can read that as date since there is no identifier. I would suggest changing the value for example you have 171054, get each 2 digits since you sure that this is represent as hh:mm:ss then add identifier between then like ":" or "-" then try us momentjs formatting again.

Where do I find the reference for TO_DATE format string

I need to convert a string formatted as MM/DD/YYYY HH:MI plus AM/PM, but can't find a complete reference to the format string to find how to specify the AM/PM part.
I would certainly appreciate information on how to do this, but would appreciate a link to a good source of documentation for this even more.
:EDIT
SELECT top 1
v.CalendarDateTime
,TO_TIMESTAMP(v.CalendarDateTime,'MM/DD/YYYY HH:MIAM') as CalendarDateTimeTS
--,CAST(TO_TIMESTAMP(v.CalendarDateTime,'MM/DD/YYYY HH:MIAM') AS TIMESTAMP(0) FORMAT 'MM/DD/YYYYBHH:MIBT') AS CalendarDateTimeTS2
12/03/2015 03:00AM 12/3/2015 03:00:00.000000
The commented out line produces a "DateTime field overflow" error.
You probably want TO_TIMESTAMP instead of TO_DATE.
The only bad thing about the Oracle function is the resulting datatype of TIMESTAMP(6) which can't be changed:
TO_TIMESTAMP('12/03/2015 03:00AM', 'MM/DD/YYYY HH:MIAM')
Using Teradata's FORMAT you can specify the timestamp precision, but it's less flexible than Oracle's, the string must match the format exactly:
CAST('12/03/2015 03:00AM' AS TIMESTAMP(0) FORMAT 'MM/DD/YYYYbHH:MIT')
On the Teradata site you'll find the (slow) online docu, e.g. TO_DATE formats or Teradata FORMATs. Of course you should download the full documentation CD for your release.
Please tell us at least which programming language are you using.
Normally it would be something like "MM/DD/YYYY HH:MI a" but we need to know first you language.

Timezone as +0000 for format-dateTime

I'm trying to format the current datetime in XSLT with an explicit UTC offset (and no other literals and no millis), like: 20140710163601+0200.
However, this <x:value-of select="format-dateTime(current-dateTime(), '[Y0001][M01][D01][H01][m01][s01][z]')"/> gives me this: 20140710164200GMT+02:00. Note that I do not want the GMT part.
If there is no offset, I get 20140710144546.
Is there any way to force an explicit offset and set it to the format I want? Obviously, I could do some string manipulation, but maybe there's a library function I'm overlooking. And then there's the no-timezone result I have to force the format for.
Note that it's no problem for me to build a function around this, but rather I'd use something built in or more elegant.
The XSLT 2.0 spec of format-dateTime() is a bit muddled about timezones, so it may depend on which processor you are using. In 3.0 it's specified that you get the format you want with [Z0000]. Recent versions of Saxon implement the function according to the 3.0 spec, but other processors may well do something different. You might be better off using timezone-from-dateTime() to extract the timezone, and then formatting it using format-number().
Try using (capital) Z instead of (lower-case) z.

Resources