DATE RANGE

UDA

DATE RANGE

Hi

I am trying to run an SQL query on the teradata datawarehouse(database) with a prompt and date range

here is the following query

select
T01.snap_shot_perd_nbr,
T01.shp_dt,inv_dt,
T01.fxgnd_shp_trk_nbr,
sum(T01.shp_fgt_chrg_amt),
sum(T01.net_rev_amt),
sum(T01.shp_piece_qty),
sum(T01.shp_accs_amt),
sum(T01.shp_disc_amt)
from fedex_ground_invoice T01
where T01.snap_shot_perd_nbr= '2009035'
AND T01.shp_dt BETWEEN ( cast( ((Start_dt ('2007-07-07', format 'yyyy-mm-dd')) (char(10)) )
|| ' ' || Start_time as timestamp(0) )
- cast( ((end_dt ('2008-10-09', format 'yyyy-mm-dd')) (char(10)) )
|| ' ' || start_time as timestamp(0) )
group by T01.snap_shot_perd_nbr,T01.shp_dt,T01.inv_dt,T01.fxgnd_shp_trk_nbr

but it displays the following msg

expected something between '(' and the string '2'.

CAN ANYBODY TELL ME WHT IS THE RIGHT SYNTAX

Thanks

Shashank
1 REPLY
rgs
Enthusiast

Re: DATE RANGE

You have a syntax error. The syntax logic tries to figure out as best as it can, what you did wrong but sometimes it does not do a good job. Assuming your post did not loose anything in the process, here are some issues:

The syntax of BETWEEN is:

You don’t have a AND in you expression so it does not know “between” what and what it is supposed to find. It looks like you are working with dates.

Your parentheses are not balanced count them there is one missing. I don’t know your intent so you need to figure out where it is supposed to go.