date format problem in table (1 Viewer)

Notsogood

Registered User.
Local time
Today, 09:45
Joined
Jan 21, 2004
Messages
86
I have a date field in my SQL database as dd/mm/yyyy but I want it the"/"s removed. I would like to have a date field as ddmmyyyy. Is that possible?
I want another field to have time as HH:MM:SS but that should be the present time.
Would someone please tell me how to do it?
Many thanks in advance
 

pdx_man

Just trying to help
Local time
Today, 01:45
Joined
Jan 23, 2001
Messages
1,347
I can't for the life of me figure out why anyone would want that format. Sorting it gives you results by the day of the month first, then month, then year. Surely this is not what you need.

But, to answer your question, leave the data stored as it is, but when displaying it, parse out the field using the DATEPART function.

It would probably be better to have a yyyymmdd format, which you can display with:
SELECT CONVERT(CHAR(8), getdate(), 112)
 

Notsogood

Registered User.
Local time
Today, 09:45
Joined
Jan 21, 2004
Messages
86
Beilive it or not, the date format needs to be in ddmmyyyy only. This is the way the interface is build and I do not have the foggiest clue how to do that.
Any ideas how? Will someone please help me?
 

pdx_man

Just trying to help
Local time
Today, 01:45
Joined
Jan 23, 2001
Messages
1,347
Then use the DATEPART function to parse your date. For the day and month, you will have to test if it is 1-9 and add a 0 in front of it.
 

Users who are viewing this thread

Top Bottom