aspose file tools*
The moose likes JDBC and the fly likes Date default in SQL Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Date default in SQL Server" Watch "Date default in SQL Server" New topic
Author

Date default in SQL Server

natx
Greenhorn

Joined: Aug 13, 2001
Posts: 4
I just started working with MS SQL Server, i imported my database from MS Access, and now i would like to set the date to a default dd/mm/yy without the time and the 4 digits in the year.
I have used getdate()but this gives me full date and time.
How can i achieve this?
Many thanks for any help.
DAYANAND BURAMSHETTY
Ranch Hand

Joined: Aug 06, 2001
Posts: 34
public String sqlDateString()
{
//U can get system time
long time= System.currentTimeMillis();
//It 's convert the system time to java.sql.Date
java.sql.Date systemsqldate=new java.sql.Date(time);

// manifulate the date using the this class
SimpleDateFormat formatter = new SimpleDateFormat ("dd-MM-yyyy");

//sqldate convert the java.util.Date because Using java.util.Date and SimpleDateFormat
// we can manifulate
java.util.Date dateString=(java.util.Date)systemsqldate;

String newDate =null;
try{
newDate = formatter.format(dateString);
}catch(Exception e){
e.printStackTrace();
}
return newDate;
}
If I'm wrong ..correct me

Dil se....,<BR>Dayanand<BR>0065-8839071(off)<BR>0065-7547034(Res0
natx
Greenhorn

Joined: Aug 13, 2001
Posts: 4
I think i understand what you want to do, but as i explained in my email this is my second day using ms sql server, and i wouldnt know where to stick all the code, i was thinking i could sort my problem out along these lines
CREATE PROCEDURE users_date
@MyDate DateTime
AS
DECLARE @DateOnly DateTime
SELECT @DateOnly = CONVERT(DateTime,CONVERT(VARCHAR(8),@MyDate,103))
SELECT *
FROM Members, Activity
WHERE cp_date = @DateOnly
(although i dont know how to connect the procedure with the two date fields in my two tables). Thanks for your help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date default in SQL Server