Get Oracle Timestamp value via orm lite in java - java-time

I have the oracle database field value "11-JUL-16 02.51.45.000000000 AM" for field date_updated.
When I retrieve records via orm lite query and iterate over the result set .. I get the data in this format "2016-7-11.2.51. 45. 0" where the java pojo object mapping field is of type String.
Aim is to update these timestamps after processing them. I am not able to covert the date to update(parse error) or retrieve the date as is.
Searched allover but couldn't find an answer. I tried changing the pojo field type to Date/Timestamp(sql) but couldn't get it to work. Any Help would really appreciate ..

Related

Casting a Firebase timestamp to a Date/Time in BigQuery - referencing a computed field again in the same query?

I am not a coder, and very much flying blind, so please excuse the simplicity of this query.
I am streaming Firebase Firestore updates to a BigQuery table using the Firebase extension "Stream collection to BigQuery" which I am then linking as a DataSource in Google Data Studio. This is currently working as intended.
I have 2 questions:
Is there a more efficient way to convert a Firebase timestamp into a BigQuery Date/Time value? The Firebase Timestamp shows in JSON format in the BigQuery table as follows:
{"created_time":{"_seconds":1647554254,"_nanoseconds":234000000}}
My BigQuery SQL code to convert it (which works) is:
DATETIME(TIMESTAMP_SECONDS(CAST(JSON_VALUE(DATA,'$.created_time._seconds') AS int64)),"Africa/Johannesburg") AS createDate
Is there a more efficient way to do this, or is this reasonable?
How do I reference the createDate computed field (above) in another computed field ageDays within this same query? I haven't found it in Google or StackOverflow, either because of poor phrasing or its just too basic a query. I tried using a table alias referencing the createDate computed field (e.g. T.createDate) but no dice. My very ugly workaround was therefore just to reperform the createDate calculation in it's entirety (which feels wrong) in my new computed column ageDays as follows:
DATE_DIFF(current_date("Africa/Johannesburg"),DATETIME(TIMESTAMP_SECONDS(CAST(JSON_VALUE(DATA,'$.created_time._seconds') AS int64)),"Africa/Johannesburg"), DAY) AS ageDays
Would be sincerely grateful for any insights - many thanks.
For your requirement, JSON_EXTRACT can also be used instead of JSON_VALUE. You can use below query to get the expected output.
select
date(timestamp_seconds(cast(json_extract( data , '$.created_time._seconds') as int64))) AS Date_Created
from `project.dataset.timetable`
Output
Table alias cannot be used to reference a field in another column with a SELECT statement as it has limited visibility. Alias can be used with Order By, Group By or Having clauses in a SELECT statement. The best way to get the ageDays is by again computing the whole createDate field.

MongoDb Date conversion

I have a large query running on a collection pulling back the date in NumberLong format, I then export to a .csv where I run a formula to convert the date to a format a human can use. Scrolling the web I am not able to find a clear way of pulling the date in 'YYY-MM-DD' format and not the NumberLong on the fly. Has anyone managed this?
If you are doing this as a once off action, one way of doing this is to use the forEach() method to convert the date and inject the new converted object into a temporary collection. Then dump that collection to CSV.
Something like this:
db.myCollection.find().forEach(function(element) {
element.dateField = new Date(element.dateField);
db.myTempCollection.insert(element);
});
Otherwise, I recommend using your programming language of choice and implementing a program or script to do the conversion.

How cast Entity Framework Date into SQL Server Date with no time part

I have a date value like '2012/01/01 12:36:55' and I want to filter SQL Server date value from this like '2012/01/01'
I can convert('2012/01/01 12:36:55', date, 102) in SQL Server to get '2012/01/01' value.
The question is : how can I convert date 2012/01/01 12:36:55' in EF LINQ query to get '2012/01/01' value when my source object still is Queryable ?
I Use EntityFunctions Class in System.Data.Objects namespace, and it works very well
http://msdn.microsoft.com/en-us/library/system.data.objects.entityfunctions.aspx
http://msdn.microsoft.com/en-us/library/bb738626.aspx

Using the Time data type in Postgres with a Microsoft Access Front-end

I have a field in my postgres database using the time (without time zone) data type. I have a Microsoft Access front-end for the database connected using psqlODBC, which reads this field as a "Date/Time" data type.
If I try to insert something into the field through the front end, I get the following error:
ODBC - insert on a linked table "table_name" failed.
ERROR: column "column_name" is of type time without time zone but expression is of type date;
I'm assuming that access is trying to input a time stamp instead.
Basically my question is it even really possible to use the time data type with Access? Or should I just be using the timestamp datatype instead?
If you are manually typing data into a linked table then no this won't be possible at present, if you have the option of updating your table via forms or VB then you could try this to get access to produce only a time value:
TimeSerial(Hour(Now()), Minute(Now()), Second(Now()))
Otherwise as you say, it's probably a good idea to change your data type to timestamp.

TIMESTAMP type in sqlite DB

I am now building an iPhone app and it involves core data. One of the entities has an attribute with Date type, which effectively generates a column with TIMESTAMP type in the corresponding sqlite DB. The value looks something like 320928592.400471
My question is... how can I convert ordinary datetime into the TIMESTAMP type? I would like to preload some static data to the DB. Therefore, I need to know how to store the data directly to the DB.
Chances are that number is the same number returned by NSDate's timeIntervalSinceReferenceDate, i.e. seconds since 1 January 2001.
It might be easier to either populate the database on the first run of your program, or to generate the prefilled database and export it from your phone to include in the bundle.