Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date conversion

Status
Not open for further replies.

jrprogr

Programmer
Jul 20, 2006
74
US
Please help me in date conversion with MMDDYYY..

select convert(varchar,'2006254',101)
 
I'm not sure that that is an acceptable date format. I cannot find an option for it. You could try something like this though?

Code:
select replace(convert(varchar,getdate(),101), '/', '')

Hope it helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
select convert(varchar,'2006254',101)

I want the below ouput for the value 2006254

01/25/2006
 
You can't get 01/25/2006 from 2006254 :))))))

Code:
SET DATEFORMAT MDY
SELECT (convert(varchar(20), CAST('20060125' as datetime),101))


Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
how are you storing your dates?

I am having trouble understanding how '2006254' should convert to 1/25/06. 4/25/06 would make a slight bit of sense.

Let me know,

Alex

Ignorance of certain subjects is a great part of wisdom
 
The values are storing in Julian format.
Instead converting to dateformat.
Can i validate rejecting the data in julian format....
 
Define 'validate rejecting the data in Julian format'

What you could do (if this is for an insert), is add

Code:
where isdate(date_field) = 1

This will kcik out anything not convertible to a date.

Hope it helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
The Julian date for 25 January is NOT 254. It's 025.

-SQLBill

Posting advice: FAQ481-4875
 
Check out THREAD183-1190041. While the Julian date format is different than yours (2 digit year vice your 4 digit year) the solution should be similar.

-SQLBill

Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top