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?