Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL Server
Expertise: Beginner
Mar 24, 1997

Dates in String Variables

Question:
I want to use a string variable with the date in it (format would be 02/22/96). How do I accomplish this?

Answer:
You'll need to first convert the date to a string (the name of the function to do this varies with each product, so you'll have to check your documentation). Then, concatenate the rest of the string around the date, for example:

SELECT string||converted_date||rest_of_string 
     FROM TableA;
The double bars are the concatenation operator. Some languages also support a correlation name (alias) if you were selecting the concatenated string as I demonstrated above. For example, you might be able to use:
SELECT string||converted_date||rest_of_string AS stringa 
     FROM TableA;
In this example, the result set would be labeled "stringa" rather than the long "string||converted_date||rest_of_string" that might appear if you do not (or can not) use a correlation name.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date