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

changing varchar into date

Status
Not open for further replies.

andreadd

MIS
Jan 15, 2008
67
CR8.5 developer SQL2000 SP4

I am writing a login report and the information of login date and time is contained in 1 field called login and it is 14 character varchar.

the raw data looks like this: 20050123 07:32 - for login of 1/23/2005 at 7:32 a.m.

What I am hoping to do is grab the first 8 characters of this field and convert it into a date and then take the last 5 characters and convert that into a time. seperate formulas.

I havent done much of this type of conversion so I am not sure how to go about it and would greatly appreciate some pointers.

Thanks
 
//{@date}:
local stringvar x := {table.stringdatetime};
date(val(left(x,4)),val(mid(x,5,2)),val(mid(x,7,2)))

//{@time}:
local stringvar x := {table.stringdatetime};
time(val(mid(x,10,2)),val(mid(x,13,2)),0)

Place these on the report, and then use format date/time to get the desired display.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top