Date conversion datenum datestr - matlab

I've processed my data by datenum(DATE(xy), 'dd-mmm-yyyy HH:MM:SS') and when I tried to convert it back to the date formate by datestr(DATE(xy), 'dd-mmm-yyyy HH:MM:SS') I've got different date. The original date was 8.4.2013 4:12:31 and the converted is 04-Oct-2013 04:12:31
Any idea, where is the error?
Thanks Tomas

What is the format of the input-date? Is it 08-04-2013 04:12:31? If it is given as 8.4.2013 4:12:31 your second input to datenum is incorrect. You specify the format: 'dd-mmm-yyyy HH:MM:SS'), while your input seems to be 8.4.2013 4:12:31.
Try:
datenum(DATE(xy), 'dd.mm.yyyy HH:MM:SS')

Related

talend format yyyy-MM-dd'T'HH:mm:ss.SSSz to yyyy-mm-dd HH:mm:ss

I am trying to change the date format in txmlmap component but its not working
i want change date format
from yyyy-MM-dd'T'HH:mm:ss.SSSz to yyyy-mm-dd HH:mm:ss
expected output:- yyyy-mm-dd HH:mm:ss
You can parse your string to a date using your source pattern and then format that date to a string using your target pattern:
TalendDate.formatDate("yyyy-mm-dd HH:mm:ss", TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ss.SSSz", myDateString))
In almost all coding languages format is text, while date is a double. That means you must first make a date of the first expression, before setting the new format of that date. But in Your case the 'T' is some kind of special format that need to be replaced with a blanck space. I have no idea about what it would look like in talend but in VB it would look like this:
' from yyyy-MM-dd'T'HH:mm:ss.SSSz to yyyy-mm-dd HH:mm:ss
DateTxt = "2022-12-01'T'22:45:10"
DateTxt = Replace(DateTxt, "'T'", " ")
MyDate = CDate(DateTxt)
MsgBox Format(MyDate, "yyyy-mm-dd HH:mm:ss")

UNIXTIMEFORMAT formula issue

I am trying to covert a timestamp value in my data to 'yyyy-mm-dd HH:mm:ss' using UNIXTIMEFORMAT formula but it is giving a wrong result as you can see in the screenshot here.
Unixtime 1592574691 translates to ==> 2020-06-19 17:51:31 but dataprep is converting to 1970-22-19 10:22:54
Your click_time is in seconds but UNIXTIMEFORMAT needs miliseconds. Try to multiply your column by 1000
UNIXTIMEFORMAT($col * 1000, 'yyyy-mm-dd HH:mm:ss')

How to convert string to date in talend

I want to convert string
1516270217
to date format
hh:mm dd-MM-YY
You can do that in a tmap for example.
TalendDate.formatDate("hh:mm dd-MM-YY",TalendDate.parseDate("HHmmddMMyy",row21.newColumn))

teradata yymmdd date format

I have a field that should be 6 digit character but it is numeric. I am using the following code to add the leading zero:
select CAST(CAST(CHD_OPEN_DATE AS FORMAT '9(6)') AS CHAR(9))
I'm using the following code to format this as a date:
cast(cast(lpad(to_char(CHD_OPEN_DATE),6,'0') as date format 'YYMMDD') as date format 'YYYY-MM-DD')
When using this date format 1990 comes up as 2090. Is there a work-around for this?
If your number has a YYMMDD format you can use the following to cast to a date without the need to cast to an intermediate string. Assuming a date range between 1930 and 2029:
SELECT 900331 AS CHD_OPEN_DATE,
Cast(CASE WHEN CHD_OPEN_DATE < 300000
THEN CHD_OPEN_DATE + 1000000
ELSE CHD_OPEN_DATE
END AS DATE)

Hive date format

Anybody converted a date from mm/dd/yyyy hh:mm format to
yyyy-mm-dd hh:mm:ss format using hive query ?
I have a string with date in the / format need to add some duration in it
Do this:
select
regexp_replace('2015/04/15','(\\d{4})\\/{1}(\\d{2})\\/{1}(\\d{2})','$1-$2-$3') as dt
from x;
INPUT:2015/04/05
OUTPUT:2015-04-05
Grab four numeric digits (\d{4}), two (\d{2}), and two more (\d{2}) from the original string and put them in that order seperated by dashes.