BookmarkSubscribeRSS Feed
EmmanuelCamden
Calcite | Level 5

I'm pulling data from a database to load into another database. The file spec I've been given says the date I need to provide be in yyyy/mm/dd hh:mm format.

The date field I'm pulling is in SQL Server and it's a datetime field, but from the SAS library side of things it shows as "Number". How can I have it export to my Excel export as a date, and in the yyyy/mm/dd hh:mm format? (e.g. 2019/04/01 00:00)

2 REPLIES 2
AnilReddy
Calcite | Level 5

Here is the formula,

 

Date DMY(
Num( Substr( :date, 7, 2 ) ),
Num( Substr( :date, 5, 2 ) ),
Num( Substr( :date, 1, 4 ) ) ) +
60 * 60 * Num( Word( 2, :date, " :" ) ) +
60 * Num( Word( -1, :date, " :" ) )

 

try this once

andreas_lds
Jade | Level 19

@EmmanuelCamden: you do know that sas stores dates, times and datetimes as numbers and that formats are used to display the values in a human-readable form?

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 679 views
  • 1 like
  • 3 in conversation