Transform string format whith month into timestamp in datastage - datastage

I want transform the string
Thu, 21 Jan 2021 09:48:38 +0100
in timestamp format "%yyyy-%mm-%dd %hh.%nn.%ss.6"
how to do?
Thank you

Check out the StringToTimestamp function and the other type conversion functions in DataStage.
You could also work with string manipulation first.
Note that you have not provided the information about the fraction of the second yet.

Related

How to get RFC1123 Date format for current date time using XSLT 2.0

I am trying to retrieve current date time in RFC1123 date format in XSLT.
has anybody tried this using XSL2.0?
I have seen code for converting various date times based on zone in XSLT2.0 and to format in specific date time format such yyyy/mm/dd or YYYY:MM:DDTHH:MM:SS.0Z, but couldnt find a way to format it to show like this
Tue, 09 Jul 2019 20:34:29 GMT
concat(date:add('1970-01-01T00:00:00',concat('PT',floor(dp:time-value() div 1000),'S')),':',dp:time-value() mod 1000)
This returns in GMT format like this 2019-07-09T21:01:26:547
How to format it for - Tue, 09 Jul 2019 20:34:29 GMT using XSLT2.0?
Use current-dateTime() to get the current date and time and then use format-dateTime to format it as needed, see the spec https://www.w3.org/TR/xslt20/#function-format-dateTime on details: a picture string
'[FNn,*-3], [D01] [MNn] [H01]:[m01]:[s01] [z]'
on my machine in German summer time gives
format-dateTime(current-dateTime(), '[FNn,*-3], [D01] [MNn] [H01]:[m01]:[s01] [z]')
as
Wed, 10 July 12:01:13 GMT+02:00
This is meant as an example on the use of format-dateTime, I haven't checked the exact details of the RFC you cited to try to implement the exact requirements.
Thanks for quick reply, your solution worked using Altova XML Spy, but unfortunately it didnt worked for me in Datapower using XSLT2.0, Not sure what was wrong, may be some issue with DP firmware version.
just for other users to make this post more helpful. I tried below 2 options which didnt work for me, but might be useful for others.
using XSLT
<xsl:value-of select="java:java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now(ZoneOffset.UTC))"></xsl:value-of>
<xsl:value-of select="format-dateTime(current-dateTime(), '[FNn,*-3], [D01] [MNn] [H01]:[m01]:[s01] [z]')"/>
So I used Gateway script to get same date format which I was looking for and stored in context variable using below
var dateNeeded = new Date()).toUTCString(); //Thu, 11 Jul 2019 21:08:12 GMT

conversion of Date : issue in IE

I have a date in following format..
"Tue Jun 21 10:52:32 +0000 2016"
Whenever i am trying to convert this date in
new Date("Tue Jun 21 10:52:32 +0000 2016") it is giving me an error says invalid date and i also tried moment("Tue Jun 21 10:52:32 +0000 2016") and moment(new Date("Tue Jun 21 10:52:32 +0000 2016")) it is giving the same error as invalid date in IE.
This issue is only in IE, in chrome it is working fine. I want the result in this format moment("Tue Jun 21 10:52:32 +0000 2016").format("dddd, MMMM Do YYYY, h:mm:ss a")
Please help me, Thanks in advance.
Don't use the Date object for its parsing abilities. You will find the implementations vary considerably across browsers. You're already using moment.js, so use its parser instead. You will have to be explicit about the input format.
var m = moment("Tue Jun 21 10:52:32 +0000 2016", "ddd MMM D H:mm:ss ZZ YYYY");
You can then format it however you like by passing a different format to the format function.
Also note that by default, moment will convert the above to the user's local time zone. If that's not what you intended, then consider using moment.parseZone instead. Refer to the user guide, and also to this blog article.

Date format in a table SAPUI5

I have created a table using SAPUI5 and I get the data to the table using ODATA service. BUt, I have a column which is of a type DATE and the format is something like this "Thu Jan 13 2011 01:00:00 GMT+0100 (Mitteleuropäische Zeit)".
I tried to google and I found this blog which is really nice.
But here I see also a jsbin example where only a single data value has been used. But I need to select one whole column "Businessdate" and format it to something like this ´13.01.2014´. Any suggestions?
The data in my source table is of type DATE.
Thanks
I have updated your jsbin example: http://jsbin.com/cika/4/edit
The changes I've made:
I have mimicked your ODate date's ISO8601 format by just setting it to the current date:
oModel.setData({
dateValue: new Date() // I.e. Mon Feb 24 2014 17:35:22 GMT+0100 (W. Europe Standard Time)
});
Just let the DatePicker control format it to your desired output format ('dd-MM-yyyy'):
new sap.ui.commons.DatePicker("date2",{
width: "10em",
value: {
path: "myModel>/dateValue",
//the format information
type: new sap.ui.model.type.Date({pattern: "dd.MM.yy"})
}
});
Hope this helps!

How to convert dates of this kind to month-day-year format?

I have to convert the following date format to m-d-Y format. How can I achieve it?
$date='Thu, 20 Jun 2013 09:09:52 UTC' and what I am suppose to pass in query is 6-20-2013
Please let me know a few quick tricks.
Thanks
date('m-d-Y', strtotime('Thu, 20 Jun 2013 09:09:52 UTC'))

Converting a string timestamp to Date results in reset to UNIX epoch

I'm having some problems converting a string to a date object in google apps script.
My dates are in the following format, from a 3rd party API:
2013-01-17T17:34:50.507
I am attempting to convert this to a Date object:
return Date(stringDate);
And this is being returned:
Thu Jan 01 01:00:00 GMT+01:00 1970
Can someone tell me what i'm doing wrong, and how to resolve this issue ?
With moment.js, it is as easy as this to parse any of ISO 8601 format.
var date = Moment.moment("2013-01-17T17:34:50.507").toDate();
You can use moment.js to parse your arbitrary date string as well.
To use moment.js in GAS, you just need to add it in the script editor.
Open your script in GAS script editor and go to "Resources" then "Libraries...", then put this project key MHMchiX6c1bwSqGM1PZiW_PxhMjh3Sh48 and click "Add". Choose the version from the dropdown, then click "Save". Now, you are ready to use moment.js in GAS.
moment.js can be used to parse date string, create formatted date string, and many other date manipulation. Thanks to the author!
You can find the moment.js documentation here.
It doesn't appear that the Date object knows how to handle that date. The date is in ISO 8601 format. Javascript can handle Dates if they are given timezone information.
You will have to do some testing, but if those dates given to you are in UTC time, then just add a Z to the end of the date string before you call new Date().
Edit: The Apps Script Date object can't seem to handle a timezone other than UTC when parsing a Date. I opened an issue for it.
It doesn't work in GScript, at least for me at the time I'm writing it.
This post serves a working alternative: How do I format this date string so that google scripts recognizes it?
As of now new Date() seems to work:
var dT = new Date("2013-01-17T17:34:50.507");
console.info("dT: %s or %d", dT, dT.getTime());
returns dT: Thu Jan 17 17:34:50 GMT+01:00 2013 or 1.358440490507E12 in Google Apps Script