If I have a table of Excel dates:
Date
-------
44197
44202
44272
44270
44241
44201
44206
How do I convert this into the MapInfo date format?
Date
20210101
20210106
20210317
20210315
20210214
20210105
20210110
Using MapBasic.
This does the trick:
Update tableName set Date = StringToDate("01/01/1900")+(Date-2)
Related
I have a timestamp pulled from MongoDB
example: 2007-01-01 01:00:00
I need it to be a simple date: 2007-01-01
Been looking at: Convert UNIX epoch to Date object
Having a hard time formatting
Using sources:
Convert column in data.frame to date
I had to assess if the class that I was trying to convert was a class that as.Date was able to take.
Turns out it was a data.frame class
Used the following to convert it:
dat_dump %>%
mutate( date = as.Date(date, format = "%Y-%m-%d"))
Hello I would like to convert string date to date format:
for example from 190424 to 2019-01-24
I try with this code :
tx_wd_df = tx_wd_df.select(
'dateTransmission',
from_unixtime(unix_timestamp('dateTransmission', 'yymmdd')).alias('dateTransmissionDATE')
)
But I got this format : 2019-01-24 00:04:00
I would like only 2019-01-24
Any idea please?
Thanks
tx_wd_df.show(truncate=False)
You can simply use to_date(). This will discard the rest of the date, and pick up only the format that matches the input date format string.
import pyspark.sql.functions as F
date_column = "dateTransmission"
# MM because mm in Java Simple Date Format is minutes, and MM is months
date_format = "yyMMdd"
df = df.withColumn(date_column, F.to_date(F.col(date_column), date_format))
I have a table where the dates are in Julian dates, and I would like to convert these dates into Calendar dates.
Here is a sample of a Julian date I have: 2457395.
In calendar date it should be: 07012016 (DDMMYYYY).
I tried to convert the date into the number of days since (01/01/1900) but even if I don't know how to have a date with a number of days as an input.
Many thanks in advance!
Impala does not support dates, only timestamps; and it does not have many date/time formatting features; so you need to be creative, e.g.
select JULIAN_DATE,
adddate('1900-01-01 00:00:00Z', JULIAN_DATE -2415021) as AS_TIMESTAMP,
to_date(adddate('1900-01-01 00:00:00Z', JULIAN_DATE -2415021)) as AS_ISO_DATE_STRING,
from_unixtime(unix_timestamp(adddate('1900-01-01 00:00:00Z', JULIAN_DATE -2415021)), "ddMMyyyy") as AS_DMY_DATE_STRING
from WHATEVER
Sample output:
julian_date as_timestamp as_iso_date_string as_dmy_date_string
----------- ------------------- ------------------ ------------------
2457395 2016-01-07 00:00:00 2016-01-07 07012016
Well if it is a JDE Julian date for example 118163 for 12-06-2018 then below code can be used
date_add(to_timestamp(concat(substr(cast(cast(118162 + 1900000 as int) as string),1,4),'01','01'),'yyyyMMdd'),
cast(substr(cast(cast(118162 + 1900000 as int) as string),5,3) as int)-1)
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)
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.