Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Incorrect Syntax

Author  Topic 

l-jeff@excite.com
Starting Member

39 Posts

Posted - 2008-06-16 : 13:48:45
I have text 060108 that I want to read 06/01/08. Here is what works.
left (oaentdate,2) + '/' + substring (oaentdate,3,2) + '/' + substring (oaendate,5,2)
However, I can't place it in the Query Select statement.

What am I doing wrong?

Lisa Jefferson

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-06-16 : 13:52:55
What do you mean by "place it in the Query Select statement"?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

l-jeff@excite.com
Starting Member

39 Posts

Posted - 2008-06-16 : 13:57:55
My query has several select statements. That is the only place where the variable is listed (oaentdate). The variable is selected from the server as 060108. I just want to add the slashes to format it as a date.

Where should I put it?

Lisa Jefferson
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-06-16 : 14:01:04
If you are using a variable, then use the variable in your code. What you have posted above is referring to a column, not a variable.

If you'd like better help than this, it would be best to tell us what screen you are looking at and also show us your code.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

l-jeff@excite.com
Starting Member

39 Posts

Posted - 2008-06-16 : 14:08:02
Select OABLDATE, OASHIPDTMM + OASHIPDTDD + OASHIPDTYY as shipdates, OAENTUSER, OAENTDATE
FROM tbl_Buffer_OpenOrders
WHERE NOT EXISTS (Select ORDERDATE, SHIPDATE, ORDER_ENTER_BY, Entered_Date_Time
FROM tbl_Data_Orders
WHERE tbl_Buffer_OpenOrders.OABL = tbl_Data_Orders.BOL AND tbl_Buffer_OpenOrders.ODLOTSEQ = tbl_Data_Orders.LINE)


I don't know where to put the code to change the text to a date format. Yes, it is a column not a variable.


Lisa Jefferson
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-16 : 14:11:29

Select OABLDATE, OASHIPDTMM + OASHIPDTDD + OASHIPDTYY as shipdates, OAENTUSER, left (oaentdate,2) + '/' + substring (oaentdate,3,2) + '/' + substring (oaendate,5,2) 
FROM tbl_Buffer_OpenOrders
WHERE NOT EXISTS (Select ORDERDATE, SHIPDATE, ORDER_ENTER_BY, Entered_Date_Time
FROM tbl_Data_Orders
WHERE tbl_Buffer_OpenOrders.OABL = tbl_Data_Orders.BOL AND tbl_Buffer_OpenOrders.ODLOTSEQ = tbl_Data_Orders.LINE)
Go to Top of Page

l-jeff@excite.com
Starting Member

39 Posts

Posted - 2008-06-16 : 14:37:43
That works! Thanks!!!!!!

Lisa Jefferson
Go to Top of Page
   

- Advertisement -