formatting date in mule 4 Dataweave - mule

I am using now() to get current datetime in Dataweave, I would like to format it so special character are removed and I get plain format like this 20200723T1720334450200

Try
now() as String {"format": "yyyyMMdd'T'HHmmssSSSSSSS"}

Related

SQL Date Formatting from String

I am stuck trying to convert the following strings formatted like this 26-09-2021-02-54-03 (DD-MM-YYYY-hh-mm-ss) into timestamp or in this format YYYY-MM-DD HH:DD:SS in BigQuery. Any idea how to process?
I cannot use PARSE_TIMESTAMP() since there is no T in the string.
Thank you
You should be able to parse it with the following:
select '26-09-2021-02-54-03'
, PARSE_TIMESTAMP("%d-%m-%Y-%H-%M-%S", '26-09-2021-02-54-03')
, FORMAT_TIMESTAMP("%F %X",PARSE_TIMESTAMP("%d-%m-%Y-%H-%M-%S", '26-09-2021-02-54-03'))
For more information on the format elements see:
https://cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions#supported_format_elements_for_timestamp

how to get date string in format dd.MM from datetime in SQL

how to get date string in format dd.MM from datetime in T-SQL.
Example
20.03 from 20.03.2019
20.03.2019 is not a standard date format assuming it is in string format so, you can use left() :
select left('20.03.2019', 5)
Easiest way would be to use the format function.
format('20.03.2019','dd.MM')

Teradata SQL: covert timestamp into format 'dd.mm.yyyyBhh:mi:ss.s(6)'

in which format should I convert timestamp to receive timestamp value like this 15.08.2017 22:17:41.860000
?
thx
You're close, you just need to Cast it to a string after adding the format:
Cast(Cast(tscol AS FORMAT 'dd.mm.yyyyBhh:mi:ss.s(6)') AS CHAR(26))
Or shorter using
To_Char(tscol,'dd.mm.yyyy hh:mi:ssff')

how to covert string datatype to date datatype in HIVE?

I have a date in string format in hive table (like "20121021") How do I convert this into "yyyy-mm-dd" (ex: 2012-10-21 or 2012/10/21)?
You can also use cast():
select cast(substr(col, 10) as date)
At least, this works for the YYYY-MM-DD format. I should also note that in a date context, a string such as YYYY-MM-DD will typically be converted automatically.
You can use TO_DATE(). Try following:
TO_DATE('20121021')
Or
from_unixtime(unix_timestamp('20121021', 'yyyyMMdd'),'yyyy-mm-dd')

Beanshell How do I convert a string to a datetime

I'm using beanshell and I need to convert a string in the format '2012.08.14 07:30:00.000' to date time integer in the format 1344925800000
Does anyone have any ideas?
Thanks in advance
Al
I hope that your example result is only an example, because using Java means I obtain a different result. But a standard is to use the number of milliseconds since January 1, 1970, 00:00:00 GMT.
I don't know if there is a more generic way, that would allow you to specify a format string. Here I use a string conversion and a format for specific locale.
import java.text.DateFormat;
sDate = "2012.08.14 07:30:00.000";
// replace beginning dots with hyphens
sDate = sDate.replaceFirst("([0-9]{4})\\.([0-9]{2})\\.([0-9]{2}) ", "$1-$2-$3 ");
// use a date format from a specified locale
formatter = DateFormat.getDateInstance(
DateFormat.MEDIUM,
new Locale("PL"));
javax.swing.JOptionPane.showMessageDialog(null,
"time=" + formatter.parse(sDate).getTime());