on 05-20-2020 5:22 PM
I have a report written in CR 2011 that I want to automate. In the SQL Query Command I have:
TICKHISD."DtTransDate" >= {d'2020-04-01'} and
I am basically pulling everything from the start of the previous month.
What do I need to do to not have the actual date in the query?
Dear Chris,
Then use the query as below
WHERE
TICKHISD."DtTransDate" >= (
SELECT ADD_MONTHS(NEXT_DAY(LAST_DAY(CURRENT_DATE)),-1) FROM DUMMY; );
Regards,
Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dell, also I'm only selecting records from the previous month. Not the start of the previous month to the current date.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm using a command. The database is a Pervasive database.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This depends on whether you're using a command or joining tables together.
If you're joining tables together, you can use Venkat's formula in the Select Expert.
However, if you're using a command, you can't use a Crystal formula. Instead you'll have to calculate the start date based on the current date using your database's syntax. If you'll let us know what type of database you're using, I should be able to provide that for you.
-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When working with your command, be sure to follow the best practices outlined here. In the Where clause of your command, you'll do something like this:
TICKHISD."DtTransDate" >= DateAdd(month, -1, DateAdd(day, -1*Day(Curdate())+1, Curdate()) and
TICKHISD."DtTransDate" <= DateAdd(day, -1*Date(Curdate()), Curdate())
I don't have access to a Pervasive database and I haven't really worked with it, but I looked up the the syntax. The basic logic for the dates is:
End Date: Subtract the number of the current day from the current date to get the last day of the previous month.
Start Date: Subtract the number of the current day from the current date, add one, then subtract 1 month to get the start day of the previous month.
-Dell
Dear Chris,
Create a formula for startDate as
date(year(currentdate),month(currentdate)-1,1)
Use that variable in the Query
TICKHISD."DtTransDate" >= {startDate}
Regards,
Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.