How to convert a numeric value into a Date value
We need to specify the origin if it is a numeric
value
as.Date(data$Date.birth, origin = "1899-12-30")
e.g.
as.Date(43067, origin = "1899-12-30")
#[1] "2017-11-28"
After converting to Date
class, if it needs to be in a custom format, use format
format(as.Date(43067, origin = "1899-12-30"), "%m/%d/%y")
#[1] "11/28/17"
If your column is factor, do convert to numeric first
as.Date(as.numeric(as.character(data$Date.birth)), origin = "1899-12-30")
Convert numeric value to date in Java
You seem to have Epoch seconds in your value, so you can use new Date(long)
using the long representation of that value times 1000:
Date d = new Date(Long.parseLong(input) * 1000);
That sets d
to Sep 15th
Converting a numeric value to date time
I have just found the way to do this.
First I have to covert the nvarchar to int then I have to convert it to date time. I have used following code:
Select convert(datetime, (convert (int, [date_column])), 6) as 'convertedDateTime' from mytable
How to convert a numeric value to date in Java?
As you have strings representing dates that have two different formats Myyyy and MMyyyy, with a SimpleDateFormat
I'm not sure you can avoid an if statement, that's how I would do it:
SimpleDateFormat sdf1 = new SimpleDateFormat("Myyyy");
SimpleDateFormat sdf2 = new SimpleDateFormat("MMyyyy");
Date d = null;
if(5 == s.length()){
d = sdf1.parse(s);
}else if(6 == s.length()){
d = sdf2.parse(s);
}
Convert a Numeric(19,0) Value to a DateTime
The Epoch Time for current date is 1553023530
while you have a value of 1868570243
(a decade in the future).
You may want to validate your data and/or methodology here Epoch Converter
Just for fun, try:
Select OddValue = dateadd(SECOND, 1868570243000 / 1000, '1970-01-01 00:00:00')
,EpochValue = dateadd(SECOND, 1552951043000 / 1000, '1970-01-01 00:00:00')
,Delta = (1868570243000 - 1552951043000) / 1000
You'll get
OddValue EpochValue Delta
2029-03-18 23:17:23.000 2019-03-18 23:17:23.000 315619200.000000
Related Topics
Why Does Nls Function Not Work in Ggplot2
Align Points and Error Bars in Ggplot When Using 'Jitterdodge'
Filter Data Table by Dynamic Column Name
Subsetting Data Based on Dynamic Column Names
R Error: Cannot Coerce Type 'Closure' to Vector of Type 'Double'
How to Log Transform the Y-Axis of R Geom_Histogram in the Right Direction
How to Load Comma Separated Data into R
How to Add a Legend for the Secondary Axis Ggplot
Empty Output When Reading a CSV File into Rstudio Using Sparkr
Select N Rows Above and Below Match
Non-Standard Evaluation and Quasiquotation in Dplyr() Not Working as (Naively) Expected
Chi Square Test for Each Row in Data Frame
Obtain Function from Akima::Interp() Matrix
R: How to Match/Join 2 Matrices of Different Dimensions (Nrow/Ncol)
R: How to Create Grid-Graphics
Assignment to Empty Index (Empty Square Brackets X[]<-) on Lhs
How to Merge Two Data Frame Based on Partial String Match with R