How to get the week day name from a date in Apache pig? - hadoop

Given "03/09/1982" how can we say it is which week day. In this case it will be "Tue".
Is it possible to get in a single query?
Thanks

You can convert this string into date object using ToDate(), then again into string with desired format using ToString(), and dont forget that Pig uses Java SimpleDateFormat class to deal with dates.
ToString( ToDate('03/09/1982','dd/MM/yyyy'), 'EEE' )

Related

Compare a date column to today's date in dax im not getting the correct output as required

I have column datetimesent through which I will get to know that the schedule is gone for today, so I'm trying to write if else query where if datetimesent is today's date then schedule running else false.
My existing column is is in date format I need to compare it with inbuilt today/now function, but they are in datetime format, I'm not getting the output correct
You can use DATE() function to build date from your timestamp
for example:
DATE(YEAR([YourTimestampColumn]),MONTH([YourTimestampColumn]),DAY([YourTimestampColumn]))

how to convert this string '2014-12-31T05:00:00.000+00:00' into date in informatica

i have my date coming in string form :'2014-12-31T05:00:00.000+00:00'
how can TO convert this into date format in informaticA
Take a sub string of the time string '2014-12-31T05:00:00.000+00:00' to '2014-12-31' after all you need date part only.
Then parse the date using to_date method.
to_date('substring date','yyyy-dd-mm')
You can use this:
to_date('2014-12-31T05:00:00.000+00:00', 'YYYY-MM-DD.HH:MI:SS.MS......')
Keep in mind that it ignores the time zone information.

Filter by time and date in Hadoop

I have a table of data which have date and time as two separate field where date format is
dd/mm/yyyy and dd-mm-yyyy and time format is like hh:mm:ss(eg: 6:52:53)
i need to filter the record for a particular time period that both time and date wise filtering.
is there any predefined filter available with hive or pig?
Hive does recognize certain strings as unixtime dates.
You might try a where condition while concatenating the time & date together into unixtime format.
Some documentation on Hive date functions/formats are located here: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-DateFunctions
I suppose you have one column having two date format ie. dd/mm/yyyy and dd-mm-yyyy
What You can try
1) Replacing '/' to '-' so that complete column will be in dd-mm-yyyy format.
2) Try concatanating this field with time field
3) filter it by Casting concatinated field.
Hope this helps.
just possibility :- Have you tried casting that concatenated field to date datatype and then try date functions for desired output ?
eg. to_date()
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF

Hive dataype for date

Date;Time;Global_active_power;Global_reactive_power;Voltage;Global_intensity;Sub_metering_1;Sub_metering_2;Sub_metering_3
16/12/2008;17:24:00;4.216;0.418;234.840;18.400;0.000;1.000;17.000
16/12/2008;17:25:00;5.360;0.436;233.630;23.000;0.000;1.000;16.000
16/12/2008;17:26:00;5.374;0.498;233.290;23.000;0.000;2.000;17.000
16/12/2008;17:27:00;5.388;0.502;233.740;23.000;0.000;1.000;17.000
16/12/2008;17:28:00;3.666;0.528;235.680;15.800;0.000;1.000;17.000
16/12/2008;17:29:00;3.520;0.522;235.020;15.000;0.000;2.000;17.000
16/12/2008;17:30:00;3.702;0.520;235.090;15.800;0.000;1.000;17.000
16/12/2008;17:31:00;3.700;0.520;235.220;15.800;0.000;1.000;17.000
16/12/2008;17:32:00;3.668;0.510;233.990;15.800;0.000;1.000;17.000
This is the sample data, i am really confused with the datatype to be used for Date and Time.
plese help,
You probably want to be looking at the TimeStamp datatype which has this format:yyyy-mm-dd hh:mm:ss
There is also a Date datatype which takes this format: YYYY-­mm-­dd
There isn't a seperate time datatype. If you can't change the sample data you probably want to load the dates as string and use udfs like unix_timestamp(string date, string pattern) then copy to result into a new table.

Using sinatra, how do I construct a proper DateTime value from 3 separate input boxes?

How do I take a numeric month, day and year from three separate text inputs and parse a proper value for my DateTime field in the db?
date = Date.civil(params[:year].to_i, params[:month].to_i, params[:day].to_i)

Resources