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

How to use CONVERT function in MS Access. 1

Status
Not open for further replies.

tatey

Programmer
Mar 15, 2001
1
DE
Starting out learning SQL and am trying to figure out exactly what the following line does when it mentions CONVERT. What is CONVERT in SQL?


select @MatDate=convert(char(8),@Date1,112)

I tried to find this in various help files but nothing there.
Thanks
ST
 
Hiya,

CONVERT is the SQL function to convert data from one type to another. Some conversions can be done implicity, eg. from int to smallint, from varchar to char. However, others need to be done explicitly, which is where convert comes in.

Now, the statment below converts the date in the field @date from a date format into a 8 character field.

select @MatDate=convert(char(8),@Date1,112)
^ ^
| |
The first part of the ------- |
convert statement is to |
define what the NEW |
data type is to be |
|
This is the column / variable to be ---
converted to the new data type.

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top