Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8047799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:13:06+00:00 2026-06-05T06:13:06+00:00

How do I convert these number columns (timestamp, event_dt) to a date or time

  • 0

How do I convert these number columns (timestamp, event_dt) to a date or time mask?
I am trying this:

    select to_char(timestamp,'YYYY-MON-DD HH24:MI:SS'), domain_c, to_char(event_date,'YYYY-MON-DD HH24:MI:SS'), total_reads from TOP_READ_EVENTS where timestamp= to_char(sysdate-2,'yyyymmdd') || '0000'
                         *
ERROR at line 1:
ORA-01481: invalid number format model


SQL> desc top_read_events;
 Name                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 YEAR                           NUMBER
 QUARTER                        NUMBER
 MONTH                          NUMBER
 DAY                            NUMBER
 HOUR                           NUMBER
 TIMESTAMP                      NUMBER
 DOMAIN_C                       VARCHAR2(255)
 EVENT_DT                       NUMBER
 TOTAL_READS                        NUMBER




select timestamp, domain_c, event_dt, total_reads from TOP_READ_EVENTS where timestamp= to_char(sysdate-2,'yyyymmdd') || '0000'    

 TIMESTAMP DOMAIN_C              EVENT_DT  TOTAL_READS
---------- ------------------------------  ------------ -------------
2.0111E+11 b.e.att-mail.com         2.0111E+11         14406
2.0111E+11 bounce.emailinfo2.bestbuy.com    2.0111E+11         14156
2.0111E+11 bounce.bluestatedigital.com      2.0111E+11         13701
2.0111E+11 plentyoffish.com         2.0111E+11         13384
2.0111E+11 mail.classmates.com          2.0111E+11         13281
2.0111E+11 comcast.net              2.0111E+11         13241
2.0111E+11 uniquelistsmail.com          2.0111E+11         13135
2.0111E+11 tankgorilla.com          2.0111E+11         12835
2.0111E+11 frigidphoenix.com            2.0111E+11         12657
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T06:13:08+00:00Added an answer on June 5, 2026 at 6:13 am

    Firstly, never store date or timestamp data-types in anything but a date or timestamp column. It causes no end of pain; as you’re gathering.

    As your “timestamps” have 11 orders of magnitude I’m going to guess that you inserted them in the form yyyymmddhh24mi, and that they’re not seconds since an unspecified epoch or anything like that.

    If you want to convert this then you have to firstly convert them into a character, then into a date. You don’t actually need a timestamp as these differ from dates only in fractional seconds.

    It’d look something like the following:

    select to_date(to_char(timestamp),'yyyymmddhh24mi') as my_timestamp
      from top_read_events
    

    On a side note never call a column timestamp, date, group or another reserved word. It causes too many problems. Personally I normally go for “tstamp” but that’s just personal preference.

    If you want to convert your “timestamp” into a character you’d then have to convert it into a character again.

    select to_char(to_date(to_char(timestamp)
                           ,'yyyymmddhh24mi')
                  ,'yyyy-mon-dd hh24:mi:ss') as my_timestamp
      from top_read_events
    

    The seconds will always be 00 as you don’t have these. Note that I only use explicit number to character to date to character conversion. It makes it more obvious to the coders who come after you what you’re doing, including yourself 2 years down the line, and there’s no chance of the interpreter making a mistake over intention and comparing a number to a character etc.

    For this reason I’d definitely change where timestamp= to_char(sysdate-2,'yyyymmdd') || '0000'. As you want to date comparison change this into a date and to it that way, i.e.

    where trunc(to_date(to_char(timestamp),'yyyymmddhh24mi'),'dd') = trunc(sysdate -2)
    

    trunc() truncates this at the day level in this instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My client receives a spreadsheet with a number of columns, one being a date.
I'm trying to convert this to dwoo: foreach($duplicates as $duplicate) { echo <tr>; foreach($column_list
I want to convert these c code to c++ code . It is about
can someboody please help me convert these strings/ints into a usable font thing? it
My Flex application records audio-only FLV files using red5--I'd like to convert these to
We are creating animations using HTML5 + Javascript. Now, we'd like to convert these
I recently switched over to using git and followed these instructions to convert my
I have some variables like these: a(1)=00:26:00 a(2)=744:32:00 a(3)=8040:33:00 I want to convert them
I saw this excellent post: http://sqldud.blogspot.com/2009/01/how-to-convert-csv-to-xml-using-c.html I have a csv file with the column
I'm trying to convert the permanent tables used in a stored procedure to global

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.