12-08-2015 02:57 PM - edited 12-08-2015 03:12 PM
I have a date variable that I am trying to report on for a specific range.
However, I am having issues tring to get the formatting of the code right.
The date format is as follows - DDMONYEAR:00:00:00.000000
I have tried the following code -
(where= ('15SEP2015:18:00:00.000000'd <= p_created_date <= '25SEP2015:18:00:00.000000'd)
Thank you for any and all help
12-08-2015 03:07 PM - edited 12-08-2015 03:08 PM
This is a datetime variable according to the format. Does your data have time stamps associated with the dates? Or are all the values of the time part of p_created_date equal to 00:00:00? The where statement is saying that you want any p_created_date between Sept 15, 2015 at 6:00 PM through Sept 25, 2015 at 6:00 PM. If you are trying to limit it with the 6:00 PM and are having issues (which I would suggest posting what the issues are), I would try eliminating the ".000000" from your datetime ranges and modifying d to dt at the end. If you are not intending to limit it with the 6:00 PM, I would suggest either changing the 18 to 00 and adding dt instead of d at the end, or just using the datepart() function of p_created_date and removing everything after the 2015 in your limits.
12-08-2015 03:22 PM
You have to remain consistent with date or datepart.
range1 = '15SEP2015:18:00:00.000000'dt;
range2 = '25SEP2015:18:00:00.000000'dt;
p_create = '20SEP2015:18:00:00.000000'dt;
format range1 range2 p_create datetime25.;
if range1 < p_create < range2 then yes = 'yes';
if datepart(range1) < '20sep2015'd < datepart(range2) then check = 'yes';
Need further help from the community? Please ask a new question.