Friday, March 30, 2012
Need help converting date format.
I have a reg_date field in my MSSQL DB which is formatted like this :
dd.mm.yy tt:mm:ss (eks. 24.12.03 18:00:03)
What i want to do is get the 8 first chars from this string so i end up with only : 24.12.03
Have tried different variations of : convert(char(8) but not sure how i do this really..
Have already searched the net for a solution but had to post it since i didn't find anything useful..
Hope someone can help me out
Best regards
Mirador-/select ((CONVERT(CHAR(6),getdate(),104)) + RIGHT(CONVERT(CHAR(10),getdate(),104),2))|||select (CONVERT(CHAR(10),getdate(),4))
using 104 adds the century to the year, which then has to be eliminated in the first response. Just using 4 returns only the last two digits of the year. Be carefule though, as this type of date format will be a problem in your code in 96 years ;-)|||Sorry, make that CHAR(8).|||Hi and thanx for the quick reply !
Have tried the code but still got trouble with this errormsg i get :
--> Incorrect syntax near '.03.'
This is the code :
SELECT bla1, bla2, bla3, bla4 FROM TABLE WHERE blabla = 1 and blabla = 0 and CONVERT(char(8), reg_date, 4) LIKE " & strTheDate.
ps!.. (strTheDate is asp variable..)
I have debugged the strTheDate and i know it's the correct format : 24.12.03 ex.
ps!.. the field is a DateTime format, just to ensure that :)
Best reagards
Mirador|||Can;t say I think this is the best way of doing this, but I haven't had enough coffee to do a re-write (and blindman will undercut me anyway).
Try this (note the single quotes!):
SELECT bla1, bla2, bla3, bla4 FROM TABLE WHERE blabla = 1 and blabla = 0 and CONVERT(char(8), reg_date, 4) = CONVERT(char(8), CAST('" & strTheDate & "' AS DATETIME),4)
This will convert strTheDate to the same format.
Need help connecting java to mssql, I'm even lost at install
Hope anyone in here can help.
I have tried to install the SQL Server 5 Express, but can't seem to get it to work properly.
I got a terrible name set as default for my database, as well as a terrible name for my username.
I can't find a place to change this to something more manageable.
It is further set to windows auth, but trying to set it to both, and trying a username (and password) always gives me a log in error.
I've tried searching all over the net and in here for a simple tutorial, but can't seem to find one that helps me more than it confuses me.
*****
The second part of the problem is that I have a java program which I want to connect to the database and use the tables in it, but I am at loss to how I can find what username (and password) I am supposed to have, what "url" it needs etc.
I have the jdbc driver so that part should work, I can successfully log to other mssql databases (at work/school), but not my own.
Hope you can help, and thanks in advance.
Hi,
to change a database name
alter database testdb
modify name = TestTmpDB
go
and to chagne user name
alter user AbolrousHazem
with Name = TempTestUser
go
while connecting to SQL Server from Java which error you get? you have wrote that you have set it with Windows Authentication, have you cross checked with Connectilon String?
HTH
Hemantgiri S. Goswami
|||Hi Murky,
I would encourage you to use the SQL Server 2005 JDBC Driver. You can download it from here: http://msdn2.microsoft.com/en-us/data/aa937724.aspx. To connect to SQL Server using the driver, please refer to the section of that page regarding building the Connection String http://msdn2.microsoft.com/en-us/library/ms378428.aspx. Note, connection string and url are synonyms. There are also many sample java applications available at the first link too.
Note that you can connection to SQL Server using two methods:
1. Username and Password Credentials
2. Windows Authentication.
To do a windows authenticated connection, the server should have been setup with "mixed-mode authentication". If you installed with all the default options, this feature was not installed then. If it was not then you need to use your username/password credentials or reconfigure the server to use mixed-mode authentication.
Hope this helps.
Regards,
Jaaved Mohammed
Need Help ASAP! FoxPro to MSSQL 2000 Conversion question..
It appears that FoxPro 2.6 stores it's null value dates as 12:00:00 AM which is causing errors when importing the data into MSSQL 2000.
The format of all of the other dates is mm/dd/yyyy
Has anyone else encountered this? is there a filter, or a a script or switch somewhere to replace the NULL values with something that MSSQL is happier with?
..:: EDIT ::..
Looking @. the properties of the affected columns, it looks like they are set as smalldatetime, but if i switch them to datetime with a length of 8 it imports just fine.
So.. now my task is to update all of the columns from smalldatetime to datetime.
sugggestions?
Thanks in advance!
Joe..::bump::..
anyone?|||Use DTS.sql
Monday, March 19, 2012
Need an allround DBA (development&Admin) in MSSQL and Oracle
International company in Australia needs an allround DBA
(development&Admin) in MSSQL and Oracle.
If you have 5+ experience in development and (not OR) Administration in
both MSSQL and Oracle and like challenges, please send CV to
rooty_hill2002@.yahoo.com.au.
I will send the position description to suitable candidates.
Cheers,
YakSorry, the email box is not shown properly. It should be
rooty_hill2002@.yahoo.com.au|||I don't know what happened! The email box is still not shown properly!
It should have "rooty_hill2002" in front of @.!