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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert Integer to Date 1

Status
Not open for further replies.

R7Dave

Programmer
Oct 31, 2007
181
US
Heelo

Is it possible to convert an integer to a date when my data looks like this

60,712

and is supposed to mean...

07/12/06

Is it possible to use CAST or CONVERT to detect this? Is it possible to assign a style? If so, how?

Thanks
Dave



 


Hi,

I think that your 'number' ought to be a 6-character string: yymmdd in CONVERT

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
something like

select cast('200'+cast(myInteger as varchar(5)) as datetime)
 
I'm curious how the dates from previous century are presented?

Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
Hello all

Previous Century Example = 910824

I have this working so far...

cast(right('0'+cast(MOrigIncep as varchar(6)),6) as datetime) as 'Inception Date',

which gives me

2006-07-12 00:00:00.000

does anybody know what I can add to make it...

07/12/06


I know I'm close, thanks for the help

Dave

 
Hello - I was able to get it - Thanks again

convert(varchar, cast(right('0'+cast(MOrigIncep as varchar(6)),6) as datetime),101) as 'Inception Date'

Displays

12/07/2006


...still looking for 2 digit year

Thanks
Dave
 
Thank you markos - I went to 50 sites and thats the first one Ive seen with mm/dd/yy (everything but)

Code:
convert(varchar, cast(right('0'+cast(MOrigIncep as varchar(6)),6) as datetime),1) as 'Inception Date',

Thanks again
 
Hmmm,
There is "Thank markros for this valuable post!" link below markros post :)


Borislav Borissov
VFP9 SP2, SQL Server 2000/2005.
 
You're welcome, I discovered this page just few days ago myself.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top