Auto insert of date

S

srigoogle

I'm trying to input some datas using preparedStatement and among those
coiumns one column is of type "smalldatetime" i wish to input the
current date and time at which i execute this query, how can i achieve
this in JDBC or what is the sql query for this.
 
B

Brendan Reynolds

I'm not sure if we're talking JET SQL or T-SQL or something else here? In
JET SQL you want the Date() function, something like ...

INSERT INTO Table1 ( TestDate )
SELECT Date() AS Expr1;

If you're using T-SQL you want the GETDATE() function, something like ...

INSERT INTO dbo.Table1
(TestDate)
SELECT GETDATE() AS Expr1
 
B

Brendan Reynolds

Oops! Almost missed something! You want the time too, so you'll want to use
Now() rather than Date() in JET SQL.
 
Top