Solved

Comparing a sas calculated date to a date in a table

Posted on 2013-06-06
1
532 Views
Last Modified: 2013-06-06
Experts,

I have a column in a table with a datea  stored as 05/01/2013
                                                                                     06/01/2013   etc.

I would like to compare the calculated date:

Dateb = date() - weekday(date()) + 1;   which is SAS format 19511

Is there a way to compare these two dates?
0
Comment
Question by:morinia
1 Comment
 
LVL 14

Accepted Solution

by:
Aloysius Low earned 500 total points
ID: 39227630
Dates in SAS is stored as a number field but can be formatted to be displayed in almost any possible combination e.g. MM/DD/YYYY, DD/MM/YYYY etc so even if it's showing as a nice looking human readable date, what's underlying is still a number offset from 01 Jan 1960..

therefore:
if DateA is already a date field, you can compare directly i.e. if DateA = DateB then

if DateA is not already a date field but a character field, you can use the input function to convert the character date to it's numerical equivalent i.e. input(DateA, MMDDYY10.) assuming the date string is in MM/DD/YYYY format, or input(DateA, DDMMYY10.) if the date string is in DD/MM/YYYY format before comparing to DateB as above
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question