BookmarkSubscribeRSS Feed
SASAna
Quartz | Level 8

Hi SAS users,

 

A filed "ENTRY_DT" is built as date format in Oracle Database, i am trying to load current date in YYYY-MM-DD format .

 

I tried to convert it into character with put function & also input function. still getting te below error, where it is inserting the records into table.

 

 

ENTRY_DT = put(today(),YYMMDD10.);

 

ERROR: ENTRY_DT, a numeric column, can only be updated with a numeric expression.

 

Thanks,

Ana

 

 

7 REPLIES 7
Tom
Super User Tom
Super User

Just assign the date value to the variable.  What format you use to display a date does not change the value that is stored in the SAS dataset (or ORACLE table).

 

entry_dt = today()

 

SASAna
Quartz | Level 8

Hi Tom,

 

Jus loading today() in the entry_dt field is giving resulsts like "1/1/1960 time".  I wanted them to be "YYYY- MM-DD" format & also todays date

Tom
Super User Tom
Super User

Sounds like you have DATETIME field instead of DATE field.  What happens if you use DATETIME() function or DHMS(today(),0,0,0) instead?

 

 

Patrick
Opal | Level 21

Please post your full code of how you want to load this date value into Oracle.

 

Be aware that a DATE column in Oracle maps to a SAS DateTime value (and NOT a SAS Date value) and though the value to load should be datetime().

http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#p06jk0u30uhuj5n18f...

 

If you're interacting with Oracle then make yourself also familiar with:

http://support.sas.com/documentation/cdl/en/acreldb/69580/HTML/default/viewer.htm#p0f64yzzxbsg8un1uw...

 

...and with:

options sastrace=',,,d' sastraceloc=saslog nostsuffix;

http://support.sas.com/documentation/cdl/en/engfedsrv/70118/HTML/default/viewer.htm#n167fxh8cc9h2an1...

 

SASAna
Quartz | Level 8

Hi Tom,

 

I tried DATETIME()  :

 

data enter;

FORMAT ENTRY_DT DATETIME20.;
ENTRY_DT = DATETIME();

run;

 

I am getting full date and time being printed in the tables. (12/19/2016 12:39:26 PM) I want it to be YYYY-MM-DD format. Table has Date format for this variable ENTRY_DT.

 

Thanks,

Ana

Tom
Super User Tom
Super User

If you want SAS to display only the date part of your datetime values you can use the DTDATE format instead of the DATETIME format.

If you to store only the date part of the current datetime time then store DHMS(TODAY(),0,0,0) instead of DATETIME().

Peter_C
Rhodochrosite | Level 12
Does the wrong presentation come from oracle or SAS ?

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 7 replies
  • 2899 views
  • 0 likes
  • 4 in conversation