DataStage Parsing Input String to Date Format - datastage

I have a string input format of i.e
'Thu, 30 Nov, 2017'
I need to transform this into a more Oracle database friendly Date type format of something like '11-30-2017' or '11/30/2017'. I started in the path of
Convert(' ','-',Convert(',','',DSLink.InputDate[5]))
which should return a string of: 30-Nov-2017
However I'm stuck on dynamically parsing the 'Nov' month part. Any clever ideas?
also I don't think this will work:
StringToDate(Convert(' ','-',Convert(',','',DSLink.InputDate[5])),"%dd-‌​%mm-%yyyy")
as the function is looking for a numeric type on the month field?

Related

SSIS: convert generated string into datetime: DT_WSTR to DT_DBDATE

I have this expression (DT_WSTR, 10)(year(getutcdate())-2)+"-01-01" that results in the string 2018-01-01.
NOw I want that string converted to a datetype but it complains that I cannot convert from DT_WSTR to DT_DBDATE (or any other datetype)
Curiously, it keeps complaining about WSTR if I try to use (DT_STR, 10,1252)(year(getutcdate())-2)+"-01-01"
How do I convert that generated string into a datetype DATE?
The ultimate goals is to get the 1st of january 2 years back at 12:00:00 AM
Since I am working on systems with different datesettings I prefer to avoid strings
Got it!
(DT_DATE)(DT_DBDATE)DATEADD("M",-MONTH(GETDATE())+1,DATEADD("D",-DAY(GETDATE())+1,DATEADD("YEAR",-2,GETUTCDATE())))

How to convert date format 'DDMONYYYY:HH....' style date in Hive

I am inserting dates that look like:
'19APR2014:08:42:32.123456'
I am interpreting their format as
'DDMONYYYY:HH24:MI:SS.FFFFFF'
Though I have not seen any times after 12:59:59 I am assuming a 24-hour clock. Hive does not seem to understand what I want to do:
HiveException: Error evaluating unix_timestamp(date_string,'DDMONYYYY:HH24:MI:SS.FFFFFF')
Any ideas what I am doing wrong or what might be wrong with my format string?
Have you tried ddMMMyyyy:HH:mm:ss.SSS? According to Hive manual a pattern string in function unix_timestamp(string date, string pattern) should comply to Java's SimpleDateFormat(see manual and javadocs).

Grails - String to date conversion

I'm trying to convert a string to a date and I'm able to do it when my string is in this format: 14/09/2016 or 09-14-2016, etc. using the new Date().parse('dd/MM/yyyy', myDateString) method. But now I have a string that looks like this: 14 September 2016. So what I want to know is what format do I give the parse method to make this work. new Date().parse('/*what goes here?*/', myDateString). Also will this method even work?
Any help would be appreciated. Thanks
Date.parse is a wrapper for SimpleDateFormat.parse, so that's where you'll want to look to find an appropriate format string. In the case of "14 September 2016", your format string would look like this: "dd MMM yyyy".
The key part for parsing this string is "MMM". From the docs:
Month: If the number of pattern letters is 3 or more, the month is
interpreted as text; otherwise, it is interpreted as a number.

converting a utc format date string to date object in Extjs

I have a date string in the format "2013-01-31T10:10:05.000Z". I want to convert this string to a Date object in extjs.
I have tried to use Ext.Date.parse("2013-01-31T10:10:05.000Z","Y-m-dTH:i:s.uZ"). But it is returning undefined.
I also tried with new Date("2013-01-31T10:10:05.000Z"), but it is also returning undefined.
Note: I have tried in IE8 browser.
Could anyone please help me to convert the above date string to Date object?
Thanks a lot sra. Now I am getting the result as ...UTC+5:30... Is there any way to convert this in IST format?
Try Ext.Date.parse("2013-01-31T10:10:05.000Z","c");
The c is the format type for ISO 8601 formatted dates
See the Ext.Date API for more details on this or other available formats
That's because 'T' and 'Z' are special characters in the Date format: http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.Date
You have to escape them like this: Ext.Date.parse("2013-01-31T10:10:05.000Z","Y-m-d\\TH:i:s.u\\Z")

Convert datetime YYYYMMDD to DDMMYYYY via T-SQL directly

i can get my datetime populated as 2012-07-24 15:31:21
However, its not in the format that i want. This is my current query
SELECT CONVERT(datetime2(0), convert(varchar(20),GETDATE() , 120))
i need the above displayed datetime in the format DD/MM/YYYY HH:MM:SS.
i have searched all over the place. Converting date format in T-SQL is available generally for datatype Varchar. Can someone advise me for datetime formatting via SQL directly?
thanks.
Either that, or you can specify the date/time format directly as the parameter of the ToString method:
string dateTime = DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss");
or second answer is
You can use any culture that supports the dd-mm-yyyy format like the french one.
For example to format the date time now in a format dd-mm-yyyy you can do as follows:
cultureInfo culture = new cultureinfo("fr-FR");
string oFormatedDate = dtNow.ToString("d", culture);