As a beginner (few months)in SAS I tried to find out how to convert a timestamp datetime30.6 to 2 variables, date and time. Date was easy, I used datepart. But I can't find a solution on SAS support for time with milliseconds.
The timepartfunction has hms (hour,minute,second) but no millisecond. Who can help me out?
Related
So, I am trying to build a query in RMAN Catalogue ( using RC_RMAN_BACKUP_JOB_DETAILS) to compare the most recent backup duration (TIME_TAKEN_DISPLAY) for each database (DB_NAME) with its historical average AVG backup duration (TIME_TAKEN_DISPLAY).
How do I convert TIME_TAKEN_DISPLAY(timestamp; HH:MM:SS), i.e. in VARCHAR2 Format to a minute format, i.e number only, so as to run the query against the entire RC_RMAN_BACKUP_JOB_DETAILS to compare AVG time taken in past with time takes for last backup for each DB.
One thing that may work is converting String(Time_taken_display)->To_TIME(Time_taken_display in Time format)->TO_NUM(Time_taken_display in minutes in number format), but this will be so highly inefficient.
The solution can be pretty simple and complex depending on the requirements:
One simple solution is:
select avg(substr(TIME_TAKEN_DISPLAY, 0,2)*60 + substr(TIME_TAKEN_DISPLAY, 4,2) + substr(TIME_TAKEN_DISPLAY, 7,2)/60) from RC_RMAN_BACKUP_JOB_DETAILS;
Using Type Casting Functions:
Cast TIME_TAKEN_DISPLAY into time format using TO_TIMESTAMP and then cast to TO_NUMBER, but I did not want to take this approach as I plan to run my scripts against all databases logged in the view, and multiple casting will leave the performance highly inefficient.
But as per #alex Poole comment, I will be using ENLAPSED_SECONDS field as it is readily available in seconds and number data type.
Suppose I need a field in tuple which should be date with time. Tarantool doesn't support date and time types out of the box.
I see two solutions:
Store date and time as string and parse it.
Store date and time in epoch seconds and convert it when needed.
What is the best solution to work with dates and times in Tarantool?
You should use UNIX time format (seconds since the beginning of the UNIX epoch) for two reasons:
- it's compact
- the desired ordering can be achieved with TREE index on 'unsigned' type.
If you deal with multiple time zones, it's best to convert to UNIX time before inserting into the database, and store the time zone in a separate field.
Support of datetime is an upcoming feature in Tarantool 2.10.0.
I'm working on optimizing some functions in which I need to convert many timestamps to UTC. My need is to create a table with the columns as follows:
YEAR | TZ_NAME | Start of Daylight Savings | End of Daylight Savings
I can convert the timestamps easily using the from_tz function in oracle, however running this per timestamp isn't an option. Does anyone know how the oracle function works? I can't find any documentation that details where oracle keeps these daylight savings rules.
Any suggestions?
Thank you!
The time zone related information is stored in a file, as per: https://docs.oracle.com/cd/B19306_01/server.102/b14225/ch4datetime.htm#i1006667
The Oracle time zone files contain the valid time zone names. The
following information is also included for each time zone:
•Offset from Coordinated Universal Time (UTC)
•Transition times for Daylight Saving Time
•Abbreviations for standard time and Daylight Saving Time
I am developing an API using Codeigniter and MongoDB.
I am not sure what date format that is the most "flexible" for the timestamp of
each document in the database.
Currently I am using: yyyy-mm-dd hh:mm:ss
Is it better (for mongodb searching and internationalization) to use another format?
My question is just this, what is the best format for a timestamp in a MongoDB document?
Over the years, I have been forced to a very strong personal commitment to always storing date/time as the 10-digit Linux/Unix timestamp, which gives the current (add: local) time as seconds since the Epoch. Just a few moments ago, the time was 1329126719. To me, this is the most flexible format possible. When it comes time to display a date/time, it's simple to convert the 10-digit timestamp to any string you care to show.
Edit: Perhaps a better choice for me would be milliseconds from the Epoch, since that seems to be increasingly favored as the art evolves.
MongoDB has a built-in datetime type which interacts with the datetime types in your application's language (in PHP they become MongoDate instances). MongoDB datetimes are always stored in UTC, and are internally stored as milliseconds since the UNIX epoch. This means that they are compact (they are always 8 bytes, as opposed to string formats which are longer depending on how much precision you choose to store). Additionally, the MongoDB tools all "understand" datetime objects -- you can manipulate them easily from javascript in a Map-Reduce, or using the new aggregation framework.
How is Oracle date implemented? Is it stored as milliseconds or something like that?
An Oracle DATE stores the date and time to the second. An Oracle TIMESTAMP stores the date and time to up to 9 digits of subsecond precision, depending on the available hardware.
Both are implemented by storing the various components of the date and the time in a packed binary format. From the Oracle Concepts Guide section on dates
Oracle uses its own internal format to
store dates. Date data is stored in
fixed-length fields of seven bytes
each, corresponding to century, year,
month, day, hour, minute, and second.
You can use the DUMP() function to see the internal representation of any particular date (or any other value for that matter), but that's probably more than you need (or want) to know.
Apparently, not in form of millisecs.
Which actually makes sense, since they do not have any running operations on current date/time:
http://www.ixora.com.au/notes/date_representation.htm
http://infolab.stanford.edu/~ullman/fcdb/oracle/or-time.html
http://www.akadia.com/services/ora_date_time.html
No. DATE is a timestamp value with seconds precision. You need TIMESTAMP(3) to store milliseconds.