I have used TalendDate.addDate(TalendDate.getCurrentDate(),-1,"DD") and the out put is "Wed Dec 28 23:51:27 IST 2016" .
I want it in "2016-12-28" format.
Is there any way to get that?
Thanks in advance.
This code will format it how you want it.
TalendDate.formatDate("yyyy-MM-dd",TalendDate.addDate(TalendDate.getCurrentDate(),-1,"DD"))
Be sure that in your output component, a date model is defined for this field.
Related
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.
I have a date in format Wed, 09 Dec 2020 10:57:15 GMT and want turn it into 09/12/2020.
If i do it with =to_date(DATEVALUE(REGEXEXTRACT(B2,"\b[0-9]{2}\s\D{3}\s[0-9]{4}\b"))) it works - the output is, like expected 09/12/2020.
But if i add IFERROR, like =iferror(to_date(DATEVALUE(REGEXEXTRACT(B2,"\b[0-9]{2}\s\D{3}\s[0-9]{4}\b"))),"") the date turns into value, like 44174.
How can i achive the correct date displaying with iferror?
use:
=IFERROR(TEXT(DATEVALUE(REGEXEXTRACT(B2, "\b[0-9]{2}\s\D{3}\s[0-9]{4}\b")),
"dd/mm/yyyy"))
I'm not positive why it works, but the following - just built on what you'd done - worked for me:
=IFERROR(to_date(text(to_date(DATEVALUE(REGEXEXTRACT(B2,"\b[0-9]{2}\s\D{3}\s[0-9]{4}\b"))),"mm/dd/yyyy")))
BTW, i figured it out to get date displayed through changing of the order of IFERROR and TO_DATE.
The working formula is now =to_date(iferror(DATEVALUE(REGEXEXTRACT(B2,"\b[0-9]{2}\s\D{3}\s[0-9]{4}\b")),"")).
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
I'm trying to format a date in Tibco Businessworks 6.2.2 in the following format:
06-AUG-2015 12:11 AM
I've found the picture string on several websites for xpath that, according to those who use them, will format the date like this. I've not been able to figure out how to only get the AUG instead of AUGUST without JUNE and JULY showing up as JUN and JUL.
Here is the xpath I'm using:
format-dateTime(current-dateTime(), '[D01]-[MNn, *-3]-[Y0001] [h01]:[m01] [PN]')
Here is the output I'm getting:
06-August-2015 12:11 AM
Any and all information is greatly appreciated.
Try this :
format-dateTime(current-dateTime(), '[D01]-[MN, *-3]-[Y0001] [h01]:[m01] [PN]')
Output :
15-DEC-2015 05:56 P.M.
ref : http://www.w3.org/TR/xslt20/#date-time-examples
In Tibco BW you can use substring on the final output - for the month'AUGUST' with index from 0 to 3. But this seems to be a work around.
A better approach is to write a common process of Date formtter with JavaCode activity from Java Palette. It doesn't and need any specific jar/lib import.
new SimpleDateFormat("yyyy-MMM-dd HH:mm a").format(new Date())
have you tried MMM in stead of MNn?
I used this function. (BW 5.12)
tib:format-dateTime('dd-MMM-yyyy hh:mm a', current-dateTime())
Out
06-Jul-2017 11:34 AM
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'))