cancel
Showing results for 
Search instead for 
Did you mean: 

Query where docdate contains '0101'

jeroenw
Participant
0 Kudos

Hi,

I made this simple query:

SELECT 
T0.[DocDate], 
T0.[CreateDate], 
T0.[DocNum], 
T0.[CardCode], 
T0.[CardName],  
T0.[Comments],
T0.DocTotal, 
T1.[firstName], 
T1.[lastName]

FROM ORDR T0 LEFT JOIN OHEM T1 ON T0.OwnerCode = T1.empID

WHERE 
T0.[DocDate] =[%0] AND 
T0.[DocStatus] = 'O' 

ORDER BY T0.[CreateDate]

This shows all open order from a specific date.

I need a query that only shows the open orders from 1 january from all years.

It must be something like this but this doesn't work:

SELECT 
T0.[DocDate], 
T0.[CreateDate], 
T0.[DocNum], 
T0.[CardCode], 
T0.[CardName],  
T0.[Comments],
T0.DocTotal, 
T1.[firstName], 
T1.[lastName]

FROM ORDR T0 LEFT JOIN OHEM T1 ON T0.OwnerCode = T1.empID

WHERE 
T0.[DocDate] Like '%%0101%%' 
T0.[DocStatus] = 'O' 

ORDER BY T0.[CreateDate]

Someone has the solution for this?

Thanks.

Accepted Solutions (0)

Answers (2)

Answers (2)

jitin_chawla
Advisor
Advisor
0 Kudos

Hi,

Check this:

SELECT 
T0.[DocDate], 
T0.[CreateDate], 
T0.[DocNum], 
T0.[CardCode], 
T0.[CardName],  
T0.[Comments],
T0.DocTotal, 
T1.[firstName], 
T1.[lastName]
FROM ORDR T0 LEFT JOIN OHEM T1 ON T0.OwnerCode = T1.empID
WHERE 
Datepart(DD,T0.DocDate) = '01' And DatePart(MM,T0.DocDate) = '01' AND
--T0.[DocDate] Like '%%0101%%' AND
T0.[DocStatus] = 'O' 
ORDER BY T0.[CreateDate]

regards,

Jitin

staseeb
Active Participant
0 Kudos

Hello jeroenw,

Try this

SELECT 
T0.[DocDate], 
T0.[CreateDate], 
T0.[DocNum], 
T0.[CardCode], 
T0.[CardName],  
T0.[Comments],
T0.DocTotal, 
T1.[firstName], 
T1.[lastName]

FROM ORDR T0 LEFT JOIN OHEM T1 ON T0.OwnerCode = T1.empID

WHERE 
month(T0.[DocDate]) = '1' and day(T0.[DocDate]) = '1'
AND T0.[DocStatus] = 'O' ORDER BY T0.[CreateDate]
Thanks
staseeb
Active Participant
0 Kudos

For hana use

SELECT 
T0.[DocDate], 
T0.[CreateDate], 
T0.[DocNum], 
T0.[CardCode], 
T0.[CardName],  
T0.[Comments],
T0.DocTotal, 
T1.[firstName], 
T1.[lastName]

FROM ORDR T0 LEFT JOIN OHEM T1 ON T0.OwnerCode = T1.empID

WHERE 
extract(month from T0.[DocDate]) = '1' and extract(day from T0.[DocDate]) = '1'
AND T0.[DocStatus] = 'O'
ORDER BY T0.[CreateDate]