BookmarkSubscribeRSS Feed
robertyknwt
Obsidian | Level 7

I've got a bunch of queries which use a few different dates in different WHERE clauses in PROC SQL statements. Some of those queries are pass-through queries to Teradata. I've gone through documentation and other questions/answers here, and tried different things to figure this out, but I haven't found the solution that works. This is what I want to do:

 

  • Prompt the user for a month and year (e.g. OCT16, like MONYY. format);
  • Calculate various dates from that prompt result (e.g. calculate 2016-10-31 and 2015-11-01 as &EndDate and &StartDate from OCT16);
  • Format those dates properly in a PROC SQL statement that is a pass-through query to one of our Teradata data warehouses, as in the following:

connect to teradata as mycon(server= dwprod3 authdomain=teradataauth mode=teradata );
create table MyTable as
select * from connection to mycon
(
Select *

From COC_V20_NOHAPHI.TABLE

WHERE TABLE.RecordDate  between &StartDate. and &EndDate.

);

3 REPLIES 3
Shmuel
Garnet | Level 18

I have searched google for "terradata date litereal" and found next link,

which I believe you'll find there the syntax:

 

http://teradataforum.com/l070316a.htm

 

example taken from there: 

Literals

Date literals can be specified in many ways:

-- in the same format as the column they are being compared to

where infamy_date = '12/07/1941'
-- with an explicit format

where infamy_date = '07Dec1941' (date, format 'DDMMMYYYY')
-- in ANSI standard form (must be preceded by the keyword DATE)

where infamy_date = date '1941-12-07'
-- in numeric form (not recommended)

where infamy_date = 411207 

 

robertyknwt
Obsidian | Level 7
Thank you! That definitely helps me on my third point.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1024 views
  • 0 likes
  • 2 in conversation