This question already has answers here:
Convert Unixtime to Datetime SQL (Oracle)
(2 answers)
Closed 9 years ago.
I have my datetime column in table defined as Oracle NUMBER data type which contains data in this format 1363709957 for example.
I want to get these numbers in query so i can execute my insert scripts which will put in current time in there. What is the oracle SQL for that?
Your time stamp appears to be a standard Unix time stamp. You need to use arithmetic to convert this here's a post on OTN about this,
and one for the other direction.
Related
This question already has answers here:
SQL Server datetime to bigint (epoch) overflow
(4 answers)
Closed 1 year ago.
im running an SSIS job that is pulling in multiple string columns into a SQL sever 2016 database, however i need to create a row index so that my job knows when to get new data. i have a date/time string column that im pulling in. i want to convert this to a unix timestamp so that i can use that in my code for when to grab new data.
is there a way to do this? my string column with the date/time that im pulling in looks like this:
'2020.07.29 08:43:53' '2021.05.03 12:50:22' etc..
what would be the best way to convert all the strings in my 'datetime' column to unix timestamps?
thanks
You can convert the string to a datetime using:
select convert(datetime, '2021.05.03 12:50:22')
You can then convert this to Unix epoch time (seconds since 1970-01-01) using:
select datediff(second, '1970-01-01', convert(datetime, '2021.05.03 12:50:22'))
Here is a db<>fiddle.
This question already has answers here:
Sqlite convert string to date
(9 answers)
Reformat dates in column
(2 answers)
sqlite change date format of every cell in column
(1 answer)
How can I convert the Date format for column in sqlite table?
(1 answer)
Closed 5 years ago.
I am currently working on a project that utilizes SQLite. I need to covert a stored date format from MM/DD/YYYY to YYYY/MM/DD. However, I don't know how to convert in SQLite.
Please take a look here:
https://sqlite.org/lang_datefunc.html
What you need is strftime function to specify the format.
This question already has answers here:
Convert SQL Server Date to mm-yyyy
(4 answers)
Closed 6 years ago.
I have an entire column that I would like to change from a complete datetime field to display only the mm-yyyy.
Don't store it in database. Let your column stay as datetime datatype use the below code to display the date in mm-yyyy format
Select right(convert(char(10),getdate(),105),7)
This question already has answers here:
How to convert SQL Server's timestamp column to datetime format
(14 answers)
Closed 9 years ago.
I am using following query but it doesn't provide any meaningful output:
Select Cast(versionno as bigint) from BranchDetail
The value in Version column is like this : 0x000000000D2537F7
A TIMESTAMP has nothing to do with date and time. See this question. It is a ROWVERSION, not a date/time value.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Oracle current_timestamp to seconds conversion
Convert Unixtime to Datetime SQL (Oracle)
I have been given a database wherein the datetime/timestamp column has been defined in NUMBER data type. What oracle function should i use to get the date time out of it?
Ex. In my table : Sample_Table, column time_touched is defined with oracle data type NUMBER. This column is supposed to be date time/timestamp. When I query the DB, I get numbers like 1355218434,1355218851 etc. These are representation of date time. But in query, what function should i use to get it display date time?
It looks like it is a UNIX timestamp (seconds since epoch 1970-01-01) where for example 1355218434 represents Tue, 11 Dec 2012 09:33:54 GMT (see converter here)
EDIT: Apparently the example below only works for MySQL, I thought that it also worked on Oracle because of the domain it is on but I was wrong. The solution is in the answer in this StackOverflow question: Convert Unixtime to Datetime SQL (Oracle)
You could use the FROM_UNIXTIME function to get what you want, see http://docs.oracle.com/cd/E17952_01/refman-5.0-en/date-and-time-functions.html#function_from-unixtime for reference.
Try something like this (untested):
SELECT FROM_UNIXTIME(time_touched) FROM Sample_Table
Your question is somewhat related to:
https://forums.oracle.com/forums/thread.jspa?threadID=2473501&tstart=75
Convert Unixtime to Datetime SQL (Oracle)