How can I get Dbeaver to translate sqlite's datetime() in editor?
Currently it just saves the function literally.
Unlike for Postgres db it translates the now() to actual datetime value.
Related
How to set current DateTime in the gremlin console?
I need to add an audit field created_on with current_timestamp as default value
Eg:
g.addV('student').property('name', 'Thirumal').property('created_on', datetime())
In, the above query, I am getting an error on datetime(). What is the syntax to add default date time?
In the Gremlin Console, you can use new Date() if you do not have a version that supports datetime(). Note that datetime() was recently added to Gremlin so you may not have the version that contains it yet. I believe it was added in the 3.5.2 release. Also please see this discussion
Without datetime() you can still do
gremlin> g.addV('test').property('date', new Date())
==>v[61287]
gremlin> g.V(61287).valueMap()
==>[date:[Thu Feb 10 10:02:18 CST 2022]]
UPDATED based on comments:
If you are using Amazon Neptune, the database provides its own version of the datetime function that expects an ISO 8601 compliant date string. So you can do something like this:
g.addV('test').property('date', datetime('2022-02-10'))
If you are using Neptune's Jupyter notebooks, to set the current date, you can create a date in a cell above (using Python) of the form
my_date = # some date calculation that yields an ISO string.
or, more concretely:
import datetime
d=datetime.datetime.now()
my_date = d.strftime('%Y-%m-%d')
and inject that string like this:
g.addV('test').property('date', datetime('${my_date}'))
In sqlite if I input such a query:
SELECT EXTRACT(YEAR FROM '2018-07-22')
I got a error. I'd like to confirm that if Sqlite support such function?
SQLite does not support EXTRACT() function.
Instead there is strftime():
SELECT strftime('%Y', '2018-07-22')
In our app the same update is executed in a SQL Server and a SQLite database.
The issue is that SQL Server works as expected however SQLite somehow is getting always 1/1/0001.
This is the update command:
UPDATE ReviewSow
SET
SowingDate = '7/1/2016 12:00:00 AM -03:00'
WHERE
ReviewSowId = 3366;
Any idea why this could be happening?
The solution was rather odd. When converting the date to ticks and passing as a string it works perfectly! Strange but this is how SQLite works.
Example:
UPDATE ReviewSow SET SowingDate = '636263784001230000' WHERE ReviewSowId = 3366;
to convert DateTime to ticks:
((DateTimeOffset)value).Ticks.ToString()
I'm using SQLite version 3.11.0 2016-02-15 17:29:24 3d862f207e3adc00f78066799ac5a8c282430a5f on Ubuntu 16.04
The query SELECT * FROM wordlist WHERE term like 'juliet' doesn't seem to return anything while the query SELECT * FROM wordlist WHERE cast(term as text) like 'juliet' returns as it should.
The datatype of the term column is blob which is also strange since I defined it as TEXT.
The problem doesn't occur in SQLite 3.8.10.2
I am using sqlite for local database in mobile and in my database. i want to know that
How to get current date format in SQLITE? I want to get date in the next format: MM/dd/yyyy
To get the current date you can use:
SELECT date('now');
Note: This is NOT a server date, it's the same time you get if you query the date and time directly from your application because SQLITE runs in-process.
It's mostly useful for putting a current time into a table or for some simple calculations if your language's date processing is very poor.
To do the calculations see the SQLITE Documentation
See the docs for formatting too for example:
SELECT strftime('%Y-%m-%d %H:%M:%S', datetime('now'))
According to the SQLite documentation as of this writing (3/30/2020), in the section titled "The DEFAULT clause", it is recommended that a constant value be used instead of a sub-query.
In my experimentation, I also ran into issues with the SQLite CREATE TABLE statement that was generated during model creation by EF Core 3.0 when using SELECT datetime('now'). The SQLite data provider complained of a syntax error when using a SELECT statement within the CREATE table statement. As such, I would recommend using the CURRENT_TIMESTAMP keyword.
for your concrete case, this is what you need:
strftime('%m/%d/%Y',date('now'))