File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes java- how to get/use current date+time in query to SQL Server database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java- how to get/use current date+time in query to SQL Server database" Watch "java- how to get/use current date+time in query to SQL Server database" New topic
Forums: Beginning Java JDBC
Author

java- how to get/use current date+time in query to SQL Server database

Arvind Ik Chari
Greenhorn

Joined: Dec 02, 2012
Posts: 13
I want to store the current date+time into a table in SQL Server.

Separately, I also want to query the table (in which date+time was stored) and then obtain the date+time as a string value in format YYYYMMDDHHMMSS.

My program is in Java, and I am basically using a SQL Azure database.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11155
    
  16

Well...what have you tried?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Arvind Ik Chari
Greenhorn

Joined: Dec 02, 2012
Posts: 13
Hi

I haven't tried anything yet-- I thought I would google about my requirement -- I have not had to use SQL Server so far(this is the first time I am storing/retrieving date in SQL Server)...and what I found is that its quite complicated to convert Java date-> SQL date.

I did search around for this requirement on Stack Overflow and CodeRanch-- I searched around for other questions similar to my own-- but the closest match on SO only deals with one part of date+time (not both date and time)

Thanks,
Arvind.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38002
    
  22
Have you found any JDBC tutorials? They might tell you about your problem. Start here.

I shall try duplicating this question in a databases forum; you might get more attention like that.
 
 
subject: java- how to get/use current date+time in query to SQL Server database
 
Similar Threads
Get current week date
JSP - JDBC alter column automatically
connet to sql server and run query
Get current week date
JSP - JDBC alter columns automatically