cancel
Showing results for 
Search instead for 
Did you mean: 

Query for selecting current date when running report

Former Member
0 Kudos

Hi all

I need a query that will copy today's date on posted sales order via DTW then that query will be linked to an alert and be sent to the sales manager every morning after the import went through successfully.

The report at the moment is running fine as i pulling through the other info required the only problem is it's pulling all the sales orrders on the system , we want it to pull only the days orders imported.

Accepted Solutions (1)

Accepted Solutions (1)

former_member583013
Active Contributor
0 Kudos

You could use either of these queries

SELECT T0.DocNum, T0.DocDueDate, T0.CardCode, T0.CardName, T0.DocTotal, T0.U_ROUTEMARKTN, T0.U_ROUNDS, T0.U_DAYOFWEEK

FROM [dbo\].[ORDR\] T0

WHERE T0.DocDate = GETDATE()

ORDER BY T0.U_ROUTEMARKTN, T0.U_ROUNDS, T0.U_DAYOFWEEK, T0.DocDueDate

OR

SELECT T0.DocNum, T0.DocDueDate, T0.CardCode, T0.CardName, T0.DocTotal, T0.U_ROUTEMARKTN, T0.U_ROUNDS, T0.U_DAYOFWEEK

FROM [dbo\].[ORDR\] T0

WHERE DATEDIFF(Day, T0.DocDate, GETDATE()) = 0

ORDER BY T0.U_ROUTEMARKTN, T0.U_ROUNDS, T0.U_DAYOFWEEK, T0.DocDueDate

Former Member
0 Kudos

Hi

your query is workin

please check this thread

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Bongani.

Try this:

WHERE day(t0.docdate) = day(getdate()) and month(t0.docdate) = month(getdate()) and  year(t0.docdate) = year(getdate())

former_member583013
Active Contributor
0 Kudos

If you could share the query I could help you filter them for the current date

Former Member
0 Kudos

Hi Suda

Please find the query below

SELECT T0.[DocNum], T0.[DocDueDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[U_ROUTEMARKTN], T0.[U_ROUNDS], T0.[U_DAYOFWEEK]

FROM [dbo].[ORDR] T0 ORDER BY T0.[U_ROUTEMARKTN], T0.[U_ROUNDS], T0.[U_DAYOFWEEK], T0.[DocDueDate]

JesperB1
Advisor
Advisor
0 Kudos

Hi Bongani,

To pull todays date from the db try - 'select getdate()'

How you want to incorporate that into your query I leave to you.

Hope it helps.

Jesper